Homework Help


QBinary search c++ lottery program 2

Change this code to a binary search,last time you gave me the same code on binary search c++ lottery program and I'm wasting pts cause the last code was mess up . Ineed a full code that can run, not a partial code a full code.




#include
using namespace std;

const int size=10;
int linearsearch(int array[], int size, int value)
{
for(int i=0; iif(array[i] == value) return 1;

}
int main()
{
int *numbers;
int N;
int count;
int results;
cout<<"How many lottery tickets were purchased?:";
cin>> N;
numbers= new int[N];
cout<<"\nEnter winning lottery ticket's numbers...\n";
for (count=0; count{
cout<<"Winning Number Lottery ticket #"<<(count+1)<<": ";
cin>>numbers[count];
}

for (count=0; count{
cout<<"\nEnter your lottery number:";
cin>>results;

if (results == 0)
{
cout<<"Quitting Program\n";
break;
}

int k=linearsearch(numbers,N,results);
if (k == 1)
cout<<"Winner!\n";
else
cout<<"Loser!\n";

}
return 0;
}
This question still have no answer summary yet.
0 answers.

This Question: "Binary search c++ lottery program 2" No answers yet.

Be the First! Or read related questions

Anonymous Sign In Sign Up
Add Answer of
Binary search c++ lottery program 2

Did this answer your question? If not, ask a new question.

Related Answers