K. I'm kinda totally lost on how to go about this....
Here's the Question:
------------------------------
Write a program that will store a list of six Lotto numbers and then invites the user to enter the latest set of Lotto numbers, including the Bonus number and checks how many matches there are for that draw.
------------------------------
I don't know how to compare two arrays which is what I think I've to do but I'm not even sure about that.. Any help would be appreciated. Thanks..
7 6504
K. I'm kinda totally lost on how to go about this....
Here's the Question:
------------------------------
Write a program that will store a list of six Lotto numbers and then invites the user to enter the latest set of Lotto numbers, including the Bonus number and checks how many matches there are for that draw.
------------------------------
I don't know how to compare two arrays which is what I think I've to do but I'm not even sure about that.. Any help would be appreciated. Thanks..
I think the first step would be to define how you are checking for the match. Do the numbers have to match in order, or can any number match (ie if 100000 is stored, will 999991 return the 1 as a match?) And what is the Bonus number - how is that handled?
I think the first step would be to define how you are checking for the match. Do the numbers have to match in order, or can any number match (ie if 100000 is stored, will 999991 return the 1 as a match?) And what is the Bonus number - how is that handled?
Well if the numbers 1 0 0 0 0 0 were the six winning numbers and 9 9 9 9 9 1 was the numbers on the ticket i would want the 1 to be counted.
The Six winning numbers I just want stored in an array or something. I want to be able to type 7 numbers to be checked including the bonus number. But is there a way for the bonus number to be kinda separate or something?? thanx.
What happens if the user gets a lotto ticket that is 1 2 3 4 5 4 and the winning numbers in the drawing are 1 1 1 1 4 4. Then how many matches are there? Do you allow both the user lotto tickets and the winning lotto tickets to repeat??
Well if the numbers 1 0 0 0 0 0 were the six winning numbers and 9 9 9 9 9 1 was the numbers on the ticket i would want the 1 to be counted.
The Six winning numbers I just want stored in an array or something. I want to be able to type 7 numbers to be checked including the bonus number. But is there a way for the bonus number to be kinda separate or something?? thanx.
Yeah, definitely.
Ok, so now that you know how you want the numbers processed, you need to come up with an algorithm - a list of simple steps on how to create your result.
The six winning lotto numbers aren't going to change, so let's say they are 7, 4, 16, 21, 35, 33. They will stay the same. I don't want to generate winning lotto numbers or anything like that. But I want to type in 7 numbers to be checked against these numbers. I want the program to be able to count how many numbers match. I don't know how to compare two arrays simply. I've read about 'bool' and all this but I only want to use the iostream class or if not possible alone then two classes. Please help... Thanx
-
#include <iostream>
-
#define MAX 6
-
#define LOT 7
-
using namespace std;
-
-
int main()
-
{
-
int number[MAX];
-
int index,temp;
-
int winnumbers[LOT];
-
int match=0;
-
-
//gather data and put it in array
-
for (index=0;index<MAX;index++)
-
{
-
cout<<"Please enter the six winning lotto numbers---> ";
-
cin>>number[index];
-
}
-
-
for (index=0;index<LOT;index++)
-
{
-
cout<<"Please enter numbers to be checked for a win ";
-
cin>>winnumbers[index];
-
}
-
-
for(int index=0;index<MAX;index++)
-
{
-
for(int temp=0;temp<LOT;temp++)
-
{
-
if(number[index]==winnumbers[temp])
-
{
-
match++; //you have a match in array2 for a value in array 1, so break the inner loop
-
-
-
-
cout<<"There are "<<match<<" matches between the two numbers."<<endl;
-
-
}
-
else
-
{
-
cout<<"";
-
}
-
}
-
}
-
-
system("PAUSE");
-
return EXIT_SUCCESS;
-
-
}
-
Please Help.. I wanna just display the number of matches... How??
looks like you almost got it. the only problem i see is if you have lotto numbers: 1 2 3 4 1 6 and someone had picked 1 7 8 9 10 11 12, the program will see 2 matches. This is because your inner loop sets the index back to 0 each time the outer loop iterates. Correct me if i'm wrong but i think it is a 1:1 ratio between winning numbers and picked numbers. in any case if you throw in an offset and restructure the inner array: that would be one way to solve your problem. -
...
-
int matches = 0;
-
// lotto array
-
for( int i = 0; i < 6; i++ )
-
{
-
// picked array
-
for( int x = 0 + matches; x < 7; x++ )
-
{
-
if( lotto[i] == picked[x] )
-
{
-
int temp = 0;
-
-
temp = picked[matches];
-
picked[matches] = picked[x];
-
picked[x] = temp;
-
-
matches++;
-
}// end of if
-
}// end of inner for
-
}// end of outer for
-
-
cout << "Congratulations! You have " << matches << " matches!\n";
-
...
-
// exit code
-
this should work, although i haven't tested it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jcs_5920 |
last post by:
Hello All, I was reading some of the posts trying to learn about date
coding schemes used in old DOS programs with no luck, so I though I'd
ask the group for help.
These are the HEX values and...
|
by: Calvin KD |
last post by:
Hi everyone,
I need help urgently.
I have a C#.Net app which uses cookies for state management (since we've
gone away from Session for fear of webfarm and we haven't found the need for
SQL Server...
|
by: almurph |
last post by:
Hi,
Hope you can help me. This is a trick one - at least I think so. I
have 2 strings. I have to calculate the "score" of the strings. Score
is determined by matching patterns of letters within...
|
by: cpptutor2000 |
last post by:
Could some PHP guru please help me? I have very standard PHP - MySQL
application that reads in some data from a table and for each row, puts
a check box at the start of the row. Now the check boxes...
|
by: marsguy85 |
last post by:
a program that repeatedly request an integer from the user and displays the integer as a binary number. It should terminate when the value 9999 is entered. A typical run might look like:
Enter...
|
by: Bsnpr8 |
last post by:
I need help guys, i have to many stuff to do, because i am in my last 2 weeks of the university, my last assignment is to do a spell checker in C++, i have an idea but nothing is coming out. I really...
|
by: ndawg123 |
last post by:
Hey guys what im trying to do is write a yatzee game with C.
And im stuck already and its the start?!?!
I want the user to type there 5 numbers.
i.e My program so far does this
Please...
|
by: karmakiller |
last post by:
Hi I have this code and it works well, but how do I add another check for valid.Surname ???
Please Help
// Validator Object
var valid = new Object();
// REGEX Elements
|
by: Simon Harvey |
last post by:
Hi all,
I'm really hoping someone can help me with this as it's causing me some
serious problems.
I have a Windows Forms application using the gridview control. When the
user selects a row,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |