King Select Prince time limit: theMs | Memory Limit:65535KB Difficulty:1
-
Describe
-
Ah, there once was a country. The country is great squad, but the king is not in good health. So I want to pick a prince to come out;
But the question came, and the king did not know how many children he had (the King was confused!) He only knew that his child's age was different. At the same time, the king also asked, he thinks the child is too old and too old, but too young and immature, (the child is too difficult to pick), he would like to age between their children is the most middle (if the number of children is even, then choose the middle of the two emperor allele older one).
-
Input
-
The first line has an integer t, which represents the T Group data (T<=10)
The second line has an integer n (0<n<=15) followed by n number representing n Prince (age is an integer)
-
Output
-
Each line outputs this string of numbers to the age of the Prince
-
Sample input
-
-
Sample output
-
23
#include <stdio.h>
#include <string.h>
int main ()
{
int t,n,i,a[16],j;
scanf ("%d", &t);
while (t--)
{
scanf ("%d", &n);
memset (a,0,sizeof (a[0));
for (i=0;i<n;i++)
scanf ("%d", &a[i]);
int temp;
for (i=0;i<n-1;i++)
for (j=i+1;j<n;j++)
if (A[i]>a[j])
{
Temp=a[i];
A[I]=A[J];
A[j]=temp;
}
printf ("%d\n", A[N/2]);
}
return 0;
}
King elect Prince