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;

}

#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.

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

- Binary search c++ lottery program 2
Binary search c++ lottery program 2...

- Binary search C++ Lottery Program
Binary search C++ Lottery Program...

- I need to write a Lottery Winners binary search C++ program
I need to write a Lottery Winners binary search C++ program...

- C++ binary search. Modify the program below to do a binary search instead of a linear search.
C++ binary search. Modify the program below to do a binary search instead of a l...

- I need to write a Lottery winners linear search C++ program
I need to write a Lottery winners linear search C++ program...

- Write a C program for binary search using at least 2 algorithms
Write a C program for binary search using at least 2 algorithms...

- Binary search 2
Binary search 2...

- Binary search
Binary search...

- binary search
binary search...

- binary search
binary search...