当前位置:网站首页>1036 Boys vs Girls
1036 Boys vs Girls
2022-07-02 05:33:00 【Brosto_Cloud】
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 name, gender, ID 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 gradeF−gradeM. 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 <iostream>
#include <string>
using namespace std;
int main() {
int n, fmax = -1, mmin = 101, score;
string fName, fId, mName, mId, name, gender, id;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> name >> gender >> id >> score ;
if (score > fmax && gender == "F") {
fName = name;
fId = id;
fmax = score;
}
if (score < mmin && gender == "M") {
mName = name;
mId = id;
mmin = score;
}
}
bool flag = 0;
if (fmax == -1) {
cout << "Absent" << endl;
flag = 1;
} else {
cout << fName << ' ' << fId << endl;
}
if (mmin == 101) {
cout << "Absent" << endl;
flag = 1;
} else {
cout << mName << ' ' << mId << endl;
}
if (flag) {
cout << "NA";
} else {
cout << fmax - mmin;
}
return 0;
}
边栏推荐
- Get the details of the next largest number
- 数据库批量插入数据
- Fabric. JS iText superscript and subscript
- 来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
- Disable access to external entities in XML parsing
- “简单”的无限魔方
- 视差特效的原理和实现方法
- Simply encapsulate JS and apply it
- Dark horse notes -- map set system
- Zzuli: maximum Convention and minimum common multiple
猜你喜欢

Gee: create a new feature and set corresponding attributes

No logic is executed after the El form is validated successfully

Fabric.js 精简JSON

How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure

Fabric.js IText 上标和下标

Gee series: Unit 1 Introduction to Google Earth engine

Using QA band and bit mask in Google Earth engine

7. Eleven state sets of TCP

Fabric.js 将本地图像上传到画布背景

Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea
随机推荐
Small and medium-sized projects to achieve certification and authorization of hand filter
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
Gee series: Unit 2 explore datasets
Sliding window on the learning road
Visual Studio導入
Gee dataset: chirps pentad high resolution global grid rainfall dataset
Youth training camp -- database operation project
Fabric.js IText设置指定文字的颜色和背景色
A collection of commonly used plug-ins for idea development tools
Fabric. JS centered element
[technical notes-08]
h5跳小程序
Pytorch Basics
Fabric.js 自由绘制矩形
Online music player app
Zzuli:1061 sequential output of digits
Appnuim environment configuration and basic knowledge
Global and Chinese market of hydrocyclone desander 2022-2028: Research Report on technology, participants, trends, market size and share
线程池概述
centos8安装mysql8.0.22教程