#include <stdio.h>
#define N 100
int aryInput(int*a)
{
int i=0;
while(1) {
if(a[i]<0)return i;
i++;
}
}
void arySort(int*a,int n)
{
int i,j,t;
for(i=0; i<n-1; i++) {
for(j=i+1; j<n; j++) {
if(a[i]>a[j]) {
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
double aryMedian(int*a,int n)
{
return (n%2)?a[n/2]:(a[n/2-1]+a[n/2])/2.0;
}
int main()
{
int ary[N],n,i;
n=aryInput(ary);
arySort(ary,n);
printf("中央値 = %g\n", aryMedian
(ary
,n
));
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgTiAxMDAKCmludCBhcnlJbnB1dChpbnQqYSkKewogIGludCBpPTA7CgogIHdoaWxlKDEpIHsKICAgIHByaW50ZigiaW5bJWRdPSIsaSk7CiAgICBzY2FuZigiJWQiLGEraSk7CiAgICBpZihhW2ldPDApcmV0dXJuIGk7CiAgICBpKys7CiAgfQp9Cgp2b2lkIGFyeVNvcnQoaW50KmEsaW50IG4pCnsKICBpbnQgaSxqLHQ7CgogIGZvcihpPTA7IGk8bi0xOyBpKyspIHsKICAgIGZvcihqPWkrMTsgajxuOyBqKyspIHsKICAgICAgaWYoYVtpXT5hW2pdKSB7CiAgICAgICAgdD1hW2ldOwogICAgICAgIGFbaV09YVtqXTsKICAgICAgICBhW2pdPXQ7CiAgICAgIH0KICAgIH0KICB9Cn0KCmRvdWJsZSBhcnlNZWRpYW4oaW50KmEsaW50IG4pCnsKICByZXR1cm4gKG4lMik/YVtuLzJdOihhW24vMi0xXSthW24vMl0pLzIuMDsKfQoKaW50IG1haW4oKQp7CiAgaW50IGFyeVtOXSxuLGk7CgogIG49YXJ5SW5wdXQoYXJ5KTsKICBhcnlTb3J0KGFyeSxuKTsKICBwcmludGYoIuS4reWkruWApCA9ICVnXG4iLCAgYXJ5TWVkaWFuKGFyeSxuKSk7CgogIHJldHVybiAwOwp9