0

I am having a problem sorting my numbers after my binary search. Can you tell me what is wrong with my code?

```
#include <iostream>
#include <cstdlib>
using namespace std;
void pick_three(int p3arr[]);
void pick_four(int p4arr[]);
void lotto(int lottoarr[]);
void selection_sort(int a[], int size);
int lottobsearch(int a[], int size);
int main()
{
int choice;
int p3arr[3];
int p4arr[4];
int lottoarr[6];
cout << "Welcome to the Maryland Lottery!\n";
do
{
cout << endl
<< "Choose 1 for Pick 3.\n"
<< "Choose 2 for Pick 4.\n"
<< "Choose 3 for Lotto.\n"
<< "Choose 4 for Mega Millions.\n"
<< "Choose 5 to Exit.\n"
<< "Enter choice and press Enter: ";
cin >> choice;
switch(choice)
{
case 1:
pick_three(p3arr);
break;
case 2:
pick_four(p4arr);
break;
case 3:
lotto(lottoarr);
break;
case 5:
cout << "End of Maryland Lottery.\n";
break;
default:
cout << "Not a valid choice.\n"
<< "Choose again.\n";
}
}
while(choice != 5);
return 0;
}
void pick_three(int p3arr[])
{
const int arrsize = 3;
p3arr[arrsize];
int rand_int = 0;
int tickets;
cout << "How many tickets?:\n";
cin >> tickets;
cout << endl;
if(tickets >=1 && tickets <=5)
{
while(tickets != 0)
{
for(int i=0; i<3; i++)
{
rand_int = rand()%10;
p3arr[i] = rand_int;
selection_sort(p3arr, arrsize);
cout << p3arr[i] << endl;
}
cout << endl;
tickets = tickets - 1;
}
}
else
{
cout << "Ticket number too large.\n";
}
return;
}
void pick_four(int p4arr[])
{
const int arrsize = 4;
p4arr[arrsize];
int rand_int = 0;
int tickets;
cout << "How many tickets?:\n";
cin >> tickets;
cout << endl;
if(tickets >=1 && tickets <=5)
{
while(tickets != 0)
{
for(int i=0; i<4; i++)
{
rand_int = rand()%10;
p4arr[i] = rand_int;
selection_sort(p4arr, arrsize);
cout << p4arr[i] << endl;
}
cout << endl;
tickets = tickets - 1;
}
}
else
{
cout << "Ticket number too large.\n";
}
return;
}
void lotto(int lottoarr[])
{
const int arrsize = 6;
lottoarr[arrsize];
int rand_int = 0;
int tickets;
cout << "How many tickets?:\n";
cin >> tickets;
cout << endl;
if(tickets >=1 && tickets <=5)
{
while(tickets != 0)
{
for(int i=0; i<6; i++)
{
rand_int = rand()%49+1;
lottoarr[i] = rand_int;
selection_sort(lottoarr, arrsize);
lottobsearch(lottoarr, arrsize);
cout << lottoarr[i] << endl;
}
cout << endl;
tickets = tickets - 1;
}
}
else
{
cout << "Ticket number too large.\n";
}
return;
}
void selection_sort(int a[], int size)
{
int temp, i, j;
for(i=0; i<size; i++)
for(j=i+1; j<size; j++)
{
if (a[i] > a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
return;
}
int lottobsearch(int a[], int size)
{
for ( int i = 0; i < size; ++i)
{
a[i] = rand()%49+1;
for (int j = 0; j < i; ++j)
{
if (a[i] == a[j])
{
a[j] = a[i];
}
}
}
return 0;
}
```