题目链接

#include <iostream>
using namespace std;
int main() {int n;scanf("%d", &n);string female, male;int femalescore = -1, malescore = 101;for(int i = 0; i < n; i++) {string name, sex, num;int score;cin >> name >> sex >> num;scanf("%d", &score);if(sex == "F") {if(femalescore < score) {femalescore = score;female = name + " " + num;}} else if(malescore > score) {malescore = score;male = name + " " + num;}}if(femalescore != -1)cout << female << endl;elseprintf("Absent\n");if(malescore != 101)cout << male << endl;elseprintf("Absent\n");if(femalescore != -1 && malescore != 101)printf("%d", femalescore - malescore);elseprintf("NA");return 0;
}
#include<iostream>
using namespace std;
const int n=10001;;int main()
{int n;cin>>n;string girl_name,girl_id;int girl_score;string boy_name,boy_id;int boy_score;for(int i=0;i<n;i++){string name,sex,id;int score;cin>>name>>sex>>id>>score;if(sex=="F")//若当前同学是女生 {if(girl_name.empty()||girl_score<score){girl_name=name;girl_id=id;girl_score=score;}}else{if(boy_name.empty()||boy_score>score){boy_name=name;boy_id=id;boy_score=score;}} }if(girl_name.empty())cout<<"Absent"<<endl;else{cout<<girl_name<<" "<<girl_id<<endl;}if(boy_name.empty())cout<<"Absent"<<endl;else{cout<<boy_name<<" "<<boy_id<<endl;}if(girl_name.size()&&boy_name.size()){cout<<abs(girl_score-boy_score)<<endl;}else{cout<<"NA"<<endl;}return 0;
}

1036 Boys vs Girls (25 分)相关推荐

  1. 【PAT甲级 排序】1036 Boys vs Girls (25 分) C++

    题目 是个水题,排序就完事. 输出女生最高分的学生,男生最低分的学生,并计算分差. 一点点小坑:让输出啥,看清楚再写,不要靠记忆做题 一开始把题目中要求输出的NA看成了NAN,一开始有两个测试用例过不 ...

  2. 1036 Boys vs Girls (25 分)_27行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 This time you are asked to tell the difference between the lowest ...

  3. A1036 Boys vs Girls 25分

    A1036 Boys vs Girls 25分 题目描述: 题目大意: 输入一个数N,以下N行每行输入一个学生信息,找到女生成绩最高的人和男生成绩最低的人,最后输出他们的名字.学号和成绩的差值. 思路 ...

  4. 1036. Boys vs Girls (25)

    以分数为核心的事件模拟 #include<iostream> #include<vector>typedef struct Student {char name[20];cha ...

  5. 1036. Boys vs Girls

    1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This ti ...

  6. PAT甲级1036 Boys vs Girls:[C++题解] 字符串处理

    文章目录 题目分析 题目链接 题目分析 分析可以看下方代码注释. ac代码 #include<bits/stdc++.h> using namespace std;int n; const ...

  7. PAT1036:Boys vs Girls

    1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This ti ...

  8. 12门课100分直博清华!这份成绩单冲上热搜,但学霸小伙也曾考过25分

    点击上方"视学算法",选择加"星标"或"置顶" 重磅干货,第一时间送达 金磊 明敏 发自 凹非寺 量子位 报道 | 公众号 QbitAI 一 ...

  9. PTA 7-3 旅游规划 (25分)(双权值Dijkstra最短路)

    7-3 旅游规划 (25分) 有了一张自驾旅游路线图,你会知道城市间的高速公路长度.以及该公路要收取的过路费.现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径.如果有若干条路 ...

最新文章

  1. boost::sort模块实现弦平面稳定测试
  2. 返回变量内容的错误示例和正确返回的4种方法
  3. 工作队列 order linux,linux 工作队列(workqueue)
  4. linux如何安装python环境变量中,Windows和linux环境下python安装及环境变量的配置
  5. JDK动态代理底层剖析
  6. 计算机项目教学法探讨,【计算机教学论文】项目教学法在计算机教学中的应用(共3594字)...
  7. 计算机组成中CM,基于TDN-CM++计算机组成原理课程设计.doc
  8. Source insight 添加注释插件
  9. clickhouse HDFS引擎
  10. ruby 基础知识(一)
  11. 贴片铝电容识别及型号_贴片式铝电解电容常用型号封装
  12. 空间自相关—莫兰指数
  13. 【微信公众号开发系列文章】一、微信公众号开发环境搭建
  14. 微信图片信息存放搜狗输入法云端服务器怎么取消,搜狗输入法弹窗怎么去掉?搜狗输入法关闭弹窗的方法...
  15. IDEA环境下模块的右下角蓝色小方块缺失的解决方法,pom文件未识别
  16. 小木工 ____农民工纪事之一
  17. Android 2.2模拟器调出中文输入法
  18. MySQL 精选 60 道笔试题
  19. Linux 压缩、解压缩命令
  20. Dobbo的继任者?试用微博RPC框架Motan

热门文章

  1. 2015美团网面试经验分享
  2. 晶圆测试开发软件,晶圆级可靠性测试:器件开发的关键步骤(一)
  3. miot-plugin-sdk 安装失败记录
  4. PostGIS教程三:创建空间数据库
  5. 定时器(Timer)的讲解
  6. Zernike条纹多项式系数(Zernike Fringe Coeffecients)
  7. 入行IT,学哪个技术前景更好?
  8. Hadoop技术内幕:深入解析MapReduce架构设计与实现原理
  9. android camera2 连拍,Android自定义Camera2 拍照,用SurfaceView预览
  10. 单片机定时器/计数器编程