PAT 1036 Boys vs Girls

原创 2015年07月10日 16:36:34
#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;
}

相关文章推荐

1036. Boys vs Girls (25)-PAT甲级真题

1036. Boys vs Girls (25) This time you are asked to tell the difference between the lowest grad...
  • liuchuo
  • liuchuo
  • 2016年08月04日 14:46
  • 122

PAT (Advanced Level) 1036. Boys vs Girls (25) 结构体排序

This time you are asked to tell the difference between the lowest grade of all the male students and...

PAT 1036. Boys vs Girls (25)

This time you are asked to tell the difference between the lowest grade of all the male students and...

Pat(Advanced Level)Practice--1036(Boys vs Girls))

Pat1036代码 题目描述: This time you are asked to tell the difference between the lowest grade of all th...

PAT (Advanced Level) Practise 1036 Boys vs Girls (25)

1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B ...

浙江大学PAT_甲级_1036. Boys vs Girls (25)

C++

PAT甲级真题及训练集(10)--1036. Boys vs Girls (25)

1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B ...

PAT-A 1036. Boys vs Girls (25)

PAT-A 1036. Boys vs Girls (25)

pat 1036. Boys vs Girls (25)

1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B ...
  • wyh7280
  • wyh7280
  • 2015年07月18日 15:23
  • 262

【PAT】1036. Boys vs Girls (25)

题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1036 题目描述: This time you are asked to tell ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:PAT 1036 Boys vs Girls
举报原因:
原因补充:

(最多只允许输入30个字)