多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > 1036. Boys vs Girls (25)

1036. Boys vs Girls (25)

來源:程序員人生   發布時間:2015-05-25 09:08:54 閱讀次數:3441次

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; struct student { char gender; int grade; string id; string name; }; int main() { int n, i; bool flag_m, flag_f; struct student student[101]; while(cin>>n) { flag_m = flag_f = false; int max_grade = 0; int min_grade = 100; int max_f = 0, min_m; for(i=0; i<n; i++) { cin>>student[i].name>>student[i].gender>>student[i].id>>student[i].grade; if(student[i].gender == 'M') { flag_m = true; if(student[i].grade <= min_grade) { min_grade = student[i].grade; min_m = i; } } else { flag_f = true; if(student[i].grade >= max_grade) { max_grade = student[i].grade; max_f = i; } } } if(flag_f) { cout<<student[max_f].name<<" "<<student[max_f].id<<endl; } else { cout<<"Absent"<<endl; } if(flag_m) { cout<<student[min_m].name<<" "<<student[min_m].id<<endl; } else { cout<<"Absent"<<endl; } if(flag_f&&flag_m) { cout<<student[max_f].grade - student[min_m].grade<<endl; } else { cout<<"NA"<<endl; } } return 0; }


生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国内免费自拍视频 | 宅男午夜在线 | 国精品日韩欧美一区二区三区 | www.黄色网 | 91精品免费久久久久久久久 | 亚洲欧洲一区二区三区 | 亚洲不卡在线播放 | poronovideos德国极品 | 最近中文版字幕在线观看 | 一区二区三区不卡在线 | 一级毛片一级毛片一级级毛片 | 久久99精品国产99久久 | 亚洲免费毛片 | 日韩 视频在线播放 | 午夜在线精品不卡国产 | 日韩一区精品 | 综合五月网 | 粉嫩00福利视频在线精品 | 黄污网 | 一本久草 | 精品欧美一区二区三区在线 | 成人香蕉xxxxxxx | 亚洲日比视频 | 成人在线精品视频 | 一区二区三区 亚洲区 | 国产欧美久久久精品影院 | 欧美日本一道高清免费3区 欧美日本一道免费一区三区 | 亚洲视频在线网 | 九九精品视频一区二区三区 | 午夜啪啪片 | 欧美性狂丰满性猛交 | 337p日本大胆欧美人术艺术精品 | 亚洲欧美日本国产 | 国产精品久久久视频 | chinese农村videoxxxx实拍 | 欧美性xxxx| 国产成人永久免费视频 | 日韩在线一区高清在线 | 欧美精品v欧洲高清 | 日本中文字幕乱码免费 | 高清视频一区二区三区 |