1036 Boys vs Girls (25 分)

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 IDare 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

分析:水题,一次过。。

 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-23-23.25.59
 * Description : A1036
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 using namespace std;
 ;
 struct student{
     string name;
     string id;
     int score;
 }temp,M,F;
 int main(){
 #ifdef ONLINE_JUDGE
 #else
     freopen("1.txt", "r", stdin);
 #endif
     M.score=;
     F.score=-;
     int n;
     char gender;
     scanf("%d",&n);
     ;i<n;i++){
         cin>>temp.name>>gender>>temp.id>>temp.score;
         if(gender=='M' && temp.score < M.score){
             M=temp;
         }
         else if(gender=='F' &&temp.score > F.score){
             F=temp;
         }
     }
     ) printf("Absent\n");
     else cout<<F.name<<" "<<F.id<<endl;
     ) printf("Absent\n");
     else cout<<M.name<<" "<<M.id<<endl;
      || M.score==) printf("NA\n");
     else printf("%d\n",F.score-M.score);
     ;
 }

1036 Boys vs Girls (25 分)的更多相关文章

  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 (25 分)

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

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

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

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

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

  5. PAT 1036 Boys vs Girls (25分) 比大小而已

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

  6. 【PAT甲级】1036 Boys vs Girls (25 分)

    题意: 输入一个正整数N(题干没指出范围,默认1e5可以AC),接下来输入N行数据,每行包括一名学生的姓名,性别,学号和分数.输出三行,分别为最高分女性学生的姓名和学号,最低分男性学生的姓名和学号,前 ...

  7. 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 ...

  8. PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)

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

  9. PATA 1036. Boys vs Girls (25)

    https://www.patest.cn/contests/pat-a-practise/1036 #include <bits/stdc++.h> using namespace st ...

  10. 1036. Boys vs Girls (25)

    #include <stdio.h>#include <string.h>int main(){ int n,i; while(scanf("%d",&am ...

随机推荐

  1. Python 爬虫常用库(九)

  2. 网页不能显示PNG验证码的解决办法

    解决方法: 开始->运行,在运行输入框中输入 “regsvr32 c:\windows\system32\pngfilt.dll”(然后点击确定)如果在注册时出现 “已加载c:\windows\ ...

  3. Redis Cluster(Redis集群)的搭建和使用

    Reids集群准备知识: (1)Redis集群介绍 Redis 集群是一个提供在多个Redis间节点间共享数据的程序集. Redis集群并不支持处理多个keys的命令,因为这需要在不同的节点间移动数据 ...

  4. JSP--TOMCAT-MYSQL web页面删除

    deleteStudentjsp.jsp页面代码 <%@ page language="java" contentType="text/html; charset= ...

  5. C# 高性能的数组 高性能数组队列实战 HslCommunication的SharpList类详解

    本文将使用一个gitHub开源的组件技术来实现这个功能 github地址:https://github.com/dathlin/HslCommunication                     ...

  6. ThinkPHP CodeIgniter URL访问举例

      ThinkPHP   URL访问:   http://localhost/think/index.php/Home/login/func/[name/syt/password/123/]   ht ...

  7. Java Iterator的一般用法

    Iterator(迭代器) 迭代器是一种设计模式,它是一个对象,它可以遍历并选择序列中的对象,而开发人员不需要了解该序列的底层结构.迭代器通常被称为“轻量级”对象,因为创建它的代价小. Java中的I ...

  8. RESTful API 学习

    /********************************************************************************* * RESTful API 学习 ...

  9. 【opencv基础】Rect类的神奇用法

    前言 最近看github上源码发现对两个cv::Rect使用相与(&)操作,猛地感觉自己蒙啦,Rect类还有这种神奇用法?!翻看opencv官网Rect类,果然如此! opencv中Rect类 ...

  10. linux下sprintf_s函数的替代

    error code: ]; sprintf_s(buf, , "predicted position:(%3d, %3d)", predict_pt.x, predict_pt. ...