您的位置:首页 > 其它

Find a girl friend

2015-11-23 18:54 211 查看

Find a girl friend


Time Limit: 1000ms Memory limit: 262144K 有疑问?点这里^_^

题目描述

CC wants to find a girl friend, he knows each girl's age and name in his class, and each girl’s age is different..
Now he wants to know the youngest girl's name and the eldest girl’s name, can you help him?

输入

Input will consist of T test cases (1≤T≤10).
The first line of each test case contains a single integer n -- the number of girls (1≤n≤50).
Each of the following n lines contains Ai, Si, the ith girl's age and name (3≤age≤80, 2≤length(name)≤20), separated by exactly one space.

Each girl’s name consists of between 2 and 20 lowercase letters.

输出

For each test case, output the youngest girl's name and the eldest girl's name, seperated by exactly one space.

示例输入

5
21 liyuchun
18 fanbingbing
19 zhangziyi
22 liuyifei
20 liuyan
1
15 yangmi


示例输出

fanbingbing liuyifei
yangmi yangmi


提示

来源

青岛理工交流赛

示例程序

#include<stdio.h>
struct set
{
int age;
char name[30];
}a[10],b,c;
int main()
{
int i,j,n,m;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
{
scanf("%d %s",&a[i].age,a[i].name);
if(i==0)
{
b=a[i];
c=a[i];
}
else
{
if(a[i].age>c.age)
c=a[i];
if(a[i].age<b.age)
b=a[i];
}
}
printf("%s %s\n",b.name,c.name);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: