1036. Boys vs Girls (25)
来源:互联网 发布:梦幻诛仙手游作弊软件 编辑:程序博客网 时间:2024/05/29 17:24
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 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:
3Joe M Math990112 89Mike M CS991301 100Mary F EE990830 95Sample Output 1:
Mary EE990830Joe Math9901126Sample Input 2:
1Jean M AA980920 60Sample Output 2:
AbsentJean AA980920NA
#include<iostream>#include<cstring>using namespace std;char name[15],ID[15],sex;int grade;int n;char M_name[15],M_ID[15];char F_name[15],F_ID[15];int M_max=1000,F_max=-1;int main(){ cin>>n; for (int i=0;i<n;i++) { cin>>name>>sex>>ID>>grade; if (sex=='M') { if (M_max>grade) { M_max=grade; strcpy(M_name,name); strcpy(M_ID,ID); } } else { if (F_max<grade) { F_max=grade; strcpy(F_name,name); strcpy(F_ID,ID); } } } if(F_max!=-1) cout<<F_name<<" "<<F_ID<<endl; else cout<<"Absent"<<endl; if(M_max!=1000) cout<<M_name<<" "<<M_ID<<endl; else cout<<"Absent"<<endl; if (F_max==-1||M_max==1000) cout<<"NA"; else cout<<F_max-M_max; return 0;}
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- 1036. Boys vs Girls (25)
- POI 大数据导出
- Intellij-Spring Initializr快速创建SpringBoot/Cloud工程。
- extern详解
- 关闭按钮清空表单内内容
- linux系统下QTcreator SDK安装和嵌入式设备QT移植详细步骤
- 1036. Boys vs Girls (25)
- Java_基础—编译期异常和运行期异常的区别
- EXCEL97版本(.xls)和EXCEL2007之后的版本(.xlsx)对比
- Train Problem I(栈和队列)
- MapDB 教程一
- Android中dp、sp、px、pt之间的换算关系
- csdn发博文
- hdu 2647 Reward(拓扑排序)
- 计算机网络读书笔记——数据链路层(3)