1036. Boys vs Girls (25)
来源:互联网 发布:长沙网络招工 编辑:程序博客网 时间:2024/06/05 14:23
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 <cstdio>#include <cstring>struct node{ char name[20], id[20], gender[5]; int score;};bool show(const node & X) { if (X.score < 0 || X.score > 100) { puts("Absent"); return false; } printf("%s %s\n", X.name, X.id); return true;}int main() { int n; scanf("%d", &n); node tmp, F, M; F.score = -1; M.score = 101; for (int i = 0; i < n; ++i) { scanf("%s%s%s%d", tmp.name, tmp.gender, tmp.id, &tmp.score); if (tmp.gender[0] == 'F' && tmp.score > F.score) F = tmp; if (tmp.gender[0] == 'M' && tmp.score < M.score) M = tmp; } bool flag = true; flag = show(F) && flag; flag = show(M) && flag; if (flag == true) printf("%d\n", F.score - M.score); else puts("NA"); 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)
- 使用开源C++项目WebSocketpp构建web服务器
- js延迟加载
- HDU1176 免费馅饼 数塔DP
- 3章数据链路层
- 转载AFNetworking源码解析(三)
- 1036. Boys vs Girls (25)
- Java网络编程
- 懒加载的动态数组添加object需要self. 不能使用_
- STL的copy真是是做的了极致的效率
- LeetCode_Jump Game
- android H264码流中的SPS获取
- 数据结构例程——归并排序
- 传奇编程大牛
- HDOJ 1000 java版