King chooses Prince 154]

Source: Internet
Author: User
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;}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.