#include<iostream>
usingnamespace std;
int lotteryList[10];
int main()
{
constint LOTTERY = 10;
int nums [LOTTERY] = {13579, 26791, 26792,33445, 55555, 62483, 77777, 79422, 85647, 93121 };
int winningNumber;
cout<<"Enter this week's winning number";
cin>>winningNumber;
for(int i=0;i<10;i++)
{
if(nums[i]==winningNumber)
{
cout<<"One of the tickets is a winner this week."<<endl;
break;
}elseif(i==9) cout<<"Not one of the tickets is a winner this week."<<endl;
}
system ("pause");
return 0;
}
set start = 0 and finish = 9. That is the range of elements in the table that you want to search.
A:
Select the middle item of the list. mid = start+finish /2
If found, you are done.
If start == finish you are done and the item was not found.
If the middle item is is greater than the search item, set finish = mid - 1
else set start = mid + 1
repeat from step A.