1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void initialize (int [], int, int);
int check (int [], int, int);
void draw (int[], int);
int entry ();
void printOut (int [], int, int);
int main(){
const int size = 10;
int wins [size];
int initVal=1;
int guess;
srand(time(NULL));
initialize (wins, size, initVal);
draw (wins, size);
guess = entry ();
int f = check (wins, size, guess);
if (f==1){
cout << "You didn't win the lottery! Better luck next time..." << endl;
printOut (wins, size, guess);
}
if (f==guess){
cout << "You won the lottery!! Congratulations!!" << endl;
printOut (wins, size, guess);
}
}
void initialize (int a[], int n, int val){
for (int i=0; i < n; i++)
a[i] = val;
}
int check (int a[], int n, int value){
for (int i=0; i < n; i++)
{
if (a[i] == value)
return i;
}
return 1;
}
void draw (int a[], int n){
int numSoFar = 0;
while (numSoFar < n){
int num = rand()%100;
int e = check (a, n, num);
if (e == 1){
a[numSoFar] = num;
numSoFar++;
}
}
}
int entry (){
int userInput;
cout << "Enter your guess <099>: ";
cin >> userInput;
return userInput;
}
void printOut (int a[], int n, int user){
cout << "The winning numbers were: ";
for (int i=0; i < n; i++)
cout << a[i] << " ";
cout << endl;
}
