关闭

PAT 1036 Boys vs Girls

标签: PAT
193人阅读 评论(0) 收藏 举报
分类:
#include<iostream>
#include<string>
using namespace std;
typedef struct student
{
string name;
string sex;
string id;
int grade;
}stu;
int main()
{
int num;
cin >> num;
stu lowest_m;
lowest_m.grade = 101;
stu highest_f;
highest_f.grade = -1;
stu tmp;
for (int i = 0; i < num; ++i)
{
cin >> tmp.name >> tmp.sex >> tmp.id >> tmp.grade;
if (tmp.sex == "M" && tmp.grade < lowest_m.grade)
{
lowest_m = tmp;
}
if (tmp.sex == "F" && tmp.grade > highest_f.grade)
{
highest_f = tmp;
}
}
int flag = 0;
if (highest_f.grade > -1)
{
cout << highest_f.name << " " << highest_f.id << endl;
}
else
{
cout << "Absent" << endl;
flag = 1;
}
if (lowest_m.grade < 101)
{
cout << lowest_m.name << " " << lowest_m.id << endl;
}
else
{
cout << "Absent" << endl;
flag = 1;
}
if (flag)
{
cout << "NA" << endl;
}
else
{
cout << highest_f.grade - lowest_m.grade << endl;
}


return 0;
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:8945次
    • 积分:343
    • 等级:
    • 排名:千里之外
    • 原创:26篇
    • 转载:0篇
    • 译文:0篇
    • 评论:2条