1036

版权声明:// Copyright © 2018年 Coding18. All rights reserved. https://blog.csdn.net/Coding18/article/details/86221402
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct student{
	char name[12];
	char id[12];
	char g;
	int grade;
}stu[20010];
int main()
{
	int n,k1 = -1,k2 = -1,high = -1,low = 1000;
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
	{
		scanf("%s %c %s %d",stu[i].name,&stu[i].g,stu[i].id,&stu[i].grade);
		if(stu[i].g == 'F' &&stu[i].grade > high)
		    {
		    	k1 = i;high = stu[i].grade;
		    }
		else if(stu[i].g == 'M' &&stu[i].grade < low)
		    {
		    	k2 = i;low = stu[i].grade;
		    }
	}
	k1>=0?printf("%s %s\n",stu[k1].name,stu[k1].id):printf("Absent\n");
	k2>=0?printf("%s %s\n",stu[k2].name,stu[k2].id):printf("Absent\n");
	k1 >=0 && k2 >= 0?printf("%d\n",stu[k1].grade - stu[k2].grade):printf("NA\n");
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Coding18/article/details/86221402
今日推荐