A lottery ticket buyer purchases 10 tickets a week. always playing the same 10 5-digit "lucky" combinations. Write a program that reads the numbers from an input file, initializes an array with these numbers and then lets the player enter this week's winning 5-digit numbers (Use random number generator to generate 5 numbers in the range 1 through 49 for the winning combinationrather than letting the user enter the winning number combination).
The program should perform both, linear and binary search though the list of the player's numbers and report whether or not one of the tickets is a winner this week. You should present the user with the menu to find out if he/she is a winner through linear or binary search.
Your code should be modular (use functions) and pass variables (by value/by reference) where appropriate.
-It started out to RUN but then after running it would just closed. I already fixed that problem but now its suppose to continue on until the user won and it doesnt. Please help me...
/* A Lottery Program which checkscthe winning number,
and the buyer is the same as the result */
#include<iostream>
using std::cout;
using std::endl;
using std::cin;
int main(int argc, char *argv[])
{
int loop, counter = 10;
int thisresult[50] = {11,18,20,24,25,
8,10,23,32,36,
1,6,12,18,34,
23,29,31,32,34,
1,15,17,23,32,
4,6,13,25,27,
8,9,26,29,34,
14,17,19,24,30,
1,8,25,28,29,
13,17,24,29,33};
// This week lottery result
int number_lottery;
// Number of user lottery
cout << "How many numbers : ";
cin >> number_lottery;
int *user_lottery = new int[number_lottery];
for (loop=0;loop<number_lottery;loop++)
{
cout << "Enter the lottery Number : ";
cin >> *(user_lottery + loop);
}
for (loop=0;loop<10;loop++)
{
if ( *(user_lottery + loop) == thisresult[loop] )
{
cout << "\n\nCONGRATULATIONS, YOU ARE THE WINNER!";
cout << "\n\nThe number is " << *(user_lottery + loop);
}
}
for (loop=0;loop<10;loop++)
{
if ( *(user_lottery + loop) == thisresult[loop] )
{
cout << "\n\nCONGRATULATIONS, YOU ARE THE WINNER!";
cout << "\n\nThe number is " << *(user_lottery + loop);
}
}
My problem is -It started out to RUN but then after running it would just closed. I already fixed that problem but now its suppose to continue on until the user won and it doesnt. Please help me...