King selected Prince time limit: 3000 MS | memory limit: 65535 kb difficulty: 1
-
Description
-
Ah, there used to be a country. The troops in this country are strong and strong, but the King is not in good health. So I wanted to pick a prince;
But the question is, the king does not know how many children he has (the king is confused !), He only knows that his children are of different ages. At the same time, the King also asked him to think that the child was too old to be peattered, and he was too young and immature (it was too difficult for the child to pick out ), he wants to be at the center of their children (if the number of children is an even number, select the older one of the two Emperors in the middle ).
-
Input
-
The first row has an integer T, representing a group of t data (T <= 10)
The second row has an integer N (0 <n <= 15), followed by N, which indicates that there are n emperors (all ages are integers)
-
Output
-
The age of the prince who output this number in each row
-
Sample Input
-
231 2 341 2 3 4
-
Sample output
-
23
-
#include<stdio.h>int main(){void sort(int a[],int n);int n,m;int a[16];scanf("%d",&n);while(n--){scanf("%d",&m);for(int i=0;i<m;i++)scanf("%d",&a[i]);sort(a,m);printf("%d\n",a[m/2]);}}void sort(int a[],int n){for(int i=0;i<n-1;i++)for(int j=0;j<n-i-1;j++){if(a[j]>a[j+1]){int t=a[j];a[j]=a[j+1];a[j+1]=t;}}}