King elect Prince

Source: Internet
Author: User

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

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.