pat(B) 1004. 成绩排名

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#define INF 1<<30
using namespace std;

int main()
{
	int n;
	int i;
	char name[15];
	char ID[15];
	int grade;
	while(scanf("%d",&n)==1)
	{
		int maxx=-INF;
		int minn=INF;
		char nx[15],nn[15],ID_x[15],ID_n[15];
		for(i=0;i<n;i++)
		{
			scanf("%s%s%d",name,ID,&grade);
			if(grade>maxx)
			{
				maxx=grade;
				strcpy(nx,name);
				strcpy(ID_x,ID);
			}
			if(grade<minn)
			{
				minn=grade;
				strcpy(nn,name);
				strcpy(ID_n,ID);
			}
		}
		printf("%s %s\n",nx,ID_x);
		printf("%s %s\n",nn,ID_n);
	}
	return 0;
}


你可能感兴趣的:(pat)