Home > Back-end >  A freshman for help
A freshman for help

Time:11-25

Do part of a question, want to write a better array for sorting (odd number) of the median, the result can't found that running in big Numbers,
Online and so on, for help,
Thank you bosses!



#include
using namespace std;
/* run this program using the console pauser or add your own getch, system (" pause ") or the input loop */
int i;//array number
Int main (int arg c, char * * argv) {
Int j, k, med;
An int array [I];
Cin> i;//input array number
for(j=0; J{
Cin> Array [j];
}
Int median (int array []);
Med=median (array);
Cout<& lt; Med<& lt; Endl;
return 0;
}
Int median (int array [])
{
Int p, q;
P=(I + 1)/2-1;//to find the middle number for further
Q=array [p].
The return of q;
}

CodePudding user response:

Failing array definition has a problem, c + + dynamic array, modified as follows, for reference:
 # include & lt; Iostream> 
using namespace std;
# define N 50
int i;//array number
Int main (int arg c, char * argv [])
{
Int j, k, med;
An int array [N].
Cin> i;//input array number
for(j=0; J{
Cin> Array [j];
}
Int median (int array []);
Med=median (array);
Cout<& lt; Med<& lt; Endl;
system("pause");
return 0;
}

Int median (int array [])
{
Int p, q;
P=(I + 1)/2-1;//to find the middle number for further
Q=array [p].
The return of q;
}
  • Related