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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
//Include Files
#include <iostream>
#include <iomanip>
using namespace std;
//Function Prototypes
int getlottoNum();
int binarySearch(int [], int, int);
bool isWinner(int);
void displayNum();
//Main Line
int main()
{
const int SIZE = 10;
int win[SIZE] = {13579, 26791, 26792, 33445, 55555, 62483, 77777, 79422, 85647, 93121};
int lottoNum;
int results;
int index;
do
{
//Ask user for lottery number
lottoNum = getlottoNum();
//Search for lottery number
index = int binarySearch(int list[], int numElems, int value);
//Display search results
}
//Validate - BOOL
isWinner(win[], lottoNum);
//Sort Numbers & print
return 0;
}
//Function Declarations
int getlottoNum()
{
int lottoNum;
cout << "What is your choice for this weeks winning lottery number?" << endl;
cin >> lottoNum;
return lottoNum;
}
int binarySearch(int array[], int numElems, int value)
{
int first = 0,
last = numElems - 1,
middle,
position = -1;
bool found = false;
while (!found && first <= last)
{
middle = (first + last) / 2;
if (array[middle] == value)
{
found = true;
position = middle;
}
else if (array[middle] > value)
last = middle - 1;
else
first = middle + 1;
}
return position;
bool isWinner(int win[], )
{
bool status;
if (lottoNum)
status = true; //winner
else
status = false;
return status;
}
//Program Output
|