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
|
#include <iostream>
using namespace std;
//declaring variables, declared globally because they are used in two files (functions)
//A stands for the first number that is drawn / input and F stands for the last one
//g_unX stores the number that the user inputs
unsigned int g_unA = 0, g_unB = 0, g_unC = 0, g_unD = 0, g_unE = 0, g_unF = 0;
//g_unLX stores the random number that the PC generates as "true value to win the lotto"
unsigned int g_unLA = 0, g_unLB = 0, g_unLC = 0, g_unLD = 0, g_unLE = 0, g_unLF = 0;
//declaring the function prototype for later use in main() even though the function is stored in calc.cpp
bool bLottoWinner (unsigned int g_unA, unsigned int g_unB, unsigned int g_unC, unsigned int g_unD, unsigned int g_unE,
unsigned int g_unF);
int main()
{
//asks the used to input his guessed values and then stores them in the g_unX int
cout << "Enter your six Lotto numbers between 1 and 49, press Enter after each one.\nEnter below:\n";
cin >> g_unA;
cin >> g_unB;
cin >> g_unC;
cin >> g_unD;
cin >> g_unE;
cin >> g_unF;
//determines if the user has won the match, and print the appropriate message to the screen
//uses the returned value of the bLottoWinner function to determine which message to print
if(bLottoWinner(g_unA, g_unB, g_unC, g_unD, g_unE, g_unF))
cout << "\nCongratulation, you have won!!" << endl;
else
{
cout << "Sorry, you have lost... Why don't you try again? \nThe correct numbers were:\n" <<
g_unLA << " " << g_unLB << " " << g_unLC << " " << g_unLD << " " << g_unLE << " " << g_unLF << endl;
}
return 0;
}
|