大家来小测一下 真的郁闷
#include<stdio.h>int Mid(int array[], int Length);
int main(void)
{
int k;
int array[] = {5,2,3,8,6};
k = Mid(array, 5);
printf("%d", k);
return 0;
}
int Mid(int array[], int Length)
{
int i, j, k, number;
k = 0;
for(i = 0; i < Length; i++);
{
for(j = 0; j < Length; j++)
{
if(array[i] > array[j])
{
k = k + 1;
}
}
if(k == (Length - 1) / 2)
{
number = array[i];
}
}
return number;
}
郁闷啊~~返回值怎么0啊???我想求中位数的,请斑竹帮忙~