1036 Boys vs Girls

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student's namegenderID and grade, separated by a space, where name and ID are strings of no more than 10 characters with no space, gender is either F(female) or M (male), and grade is an integer between 0 and 100. It is guaranteed that all the grades are distinct.

Output Specification:

For each test case, output in 3 lines. The first line gives the name and ID of the female student with the highest grade, and the second line gives that of the male student with the lowest grade. The third line gives the difference grade​F​​−grade​M​​. If one such kind of student is missing, output Absent in the corresponding line, and output NA in the third line instead.

Sample Input 1:

3
Joe M Math990112 89
Mike M CS991301 100
Mary F EE990830 95

Sample Output 1:

Mary EE990830
Joe Math990112
6

Sample Input 2:

1
Jean M AA980920 60

Sample Output 2:

Absent
Jean AA980920
NA
#include<cstdio>
#include<iostream>

using namespace std;

struct pNode{
	char name[11];
	char gender;
	char ID[11];
	int grade;
}temp,ans1,ans2;

int main()
{
	ans1.grade=100;
	ans2.grade=0;
	bool malet=0,femalet=0,na=0;
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%s %s %s %d",temp.name,&temp.gender,temp.ID,&temp.grade);
		if(temp.gender=='M')
		{
			if(temp.grade<ans1.grade)
			{
				ans1 = temp;
			}
			malet=true;
		}
		else if(temp.gender=='F')
		{
			if(temp.grade>ans2.grade)
			{
				ans2 = temp;
			}
			femalet=true;
		}
	}
	if(femalet==true)
	{
	printf("%s %s\n",ans2.name,ans2.ID);
	}
	else
	{
	printf("Absent\n");
	na=true;
	}

	if(malet==true)
	{
	printf("%s %s\n",ans1.name,ans1.ID);
	}
	else
	{
	printf("Absent\n");
	na=true;
	}
	if(malet==true&&femalet==true)
	{
		printf("%d",ans2.grade-ans1.grade);
	}
	if(na==true)
	{
		printf("NA");
	}

	return 0;
 } 

PAT甲级——1036 Boys vs Girls的更多相关文章

  1. PAT 甲级 1036 Boys vs Girls (25 分)(简单题)

    1036 Boys vs Girls (25 分)   This time you are asked to tell the difference between the lowest grade ...

  2. PAT 甲级 1036 Boys vs Girls(20)

    https://pintia.cn/problem-sets/994805342720868352/problems/994805453203030016 This time you are aske ...

  3. PAT Advanced 1036 Boys vs Girls (25 分)

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  4. PAT甲级——A1036 Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  5. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  6. PAT 1036 Boys vs Girls[简单]

    1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...

  7. PAT 1036 Boys vs Girls (25 分)

    1036 Boys vs Girls (25 分)   This time you are asked to tell the difference between the lowest grade ...

  8. 1036 Boys vs Girls (25 分)

    1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...

  9. 1036 Boys vs Girls (25分)(水)

    1036 Boys vs Girls (25分)   This time you are asked to tell the difference between the lowest grade o ...

随机推荐

  1. ArchLinux安装Gnome桌面

    给Arch安装Gnome桌面美化及常用软件配置 一.创建普通用户 1.安装zsh 个人比较喜欢的一个shell,你们可以和我不同 # pacman -S zsh 2.创建用户 kain是我创建用户的名 ...

  2. 高级css效果

    1.图片渐变效果 background linear-gradient(top,rgba(0,0,0,.8),rgba(0,0,0,.8))

  3. python安装wordcloud、jieba,pyecharts

    1.安装wordcloud: 适用于无法使用pip install wordcloud安装的情况: 据python和windows 版本 到https://www.lfd.uci.edu/~gohlk ...

  4. 学生选课系统(Java语言期末前测试)

      测试具体要求: 2.系统要求与功能设计 2.1 页面要求 (1)能够在Tomcat服务器中正确部署,并通过浏览器查看: (2)网站页面整体风格统一: (3)首页(登录页)要求实现不同用户登录后,进 ...

  5. docker 批量命令

    docker中 启动所有的容器命令: docker start $(docker ps -a | awk '{ print $1}' | tail -n +2) docker中    关闭所有的容器命 ...

  6. jupyter notebook 安装配置使用,+目录插件安装

    1.安装 pip3 install jupyter 2.配置 2.1. 生成一个 notebook 配置文件 jupyter notebook --generate-config /root/.jup ...

  7. [极客大挑战 2019]Secret File

    0x00知识点 没有过滤file 使用php的file伪协议去读取文件 ?file=php://filter/convert.base64-encode/resource=flag.php 0x01解 ...

  8. MySQL--主备相关命令

    创建用户账号 GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO repl@'10.70.8.%' IDENTIFIED BY 'mysql'; ...

  9. JavaScript—面向对象小例子

    什么是面向对象 要是以前别人问我.随口道来,封装继承多态,万物皆对象...一大推.说的自己都以为自己掌握了面向对象.呵呵一笑.确实掌握了 只是不会用..... 什么是面向对象编程 以前 学.Net 虽 ...

  10. HTML 的 元素分析

    一一元素分类 常用的块状元素有: <div>.<p>.<h1>...<h6>.<ol>.<ul>.<dl>.< ...