Lottery Program (doesnt work) C++

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.

Here are the numbers:

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

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);
}

cout << "\n\nComparison is being processed\n\n";
counter = 10;
while(counter > 0)
{
cout << counter << "!" << "\n";
counter--;
}

// -------------------------------------
// Comparison Part/Linear Search

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);
}
}

system ("PAUSE");
return 0;
}
I tried reading that and it just made me angry. Format it properly, use code tags
Centered code? And small font? Wtf? ^Please do the above.
/* 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);
}

cout << "\n\nComparison is being processed\n\n";
counter = 10;
while(counter > 0)
{
cout << counter << "!" << "\n";
counter--;
}

// -------------------------------------
// Comparison Part/Linear Search

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);
}
}

system ("PAUSE");
return 0;
}



I didnt have the centered button checked!
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...

Topic archived. No new replies allowed.