PAT甲题题解-1036. Boys vs Girls (25)-找最大最小,大水题
题意:给出n个人的姓名、性别、ID、分数,让你找出其中哪个妹纸分数最高、哪个汉子分数最低、以及他们的差
如果没有妹纸或者汉子,则对应输出Absent,差用NA代替。
就是for一遍找最大最小值,水题
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <vector>
#define INF 0x3f3f3f3f
using namespace std;
struct Node{
char name[];
char ID[];
int grade;
}male,female,tmp;
int main()
{
int n;
char str[];
scanf("%d",&n);
male.grade=INF;
female.grade=-;
for(int i=;i<n;i++){
scanf("%s %s %s %d",tmp.name,str,tmp.ID,&tmp.grade);
if(str[]=='M'){
if(tmp.grade<male.grade){
strcpy(male.name,tmp.name);
strcpy(male.ID,tmp.ID);
male.grade=tmp.grade;
}
}
else{
if(tmp.grade>female.grade){
strcpy(female.name,tmp.name);
strcpy(female.ID,tmp.ID);
female.grade=tmp.grade;
}
}
}
bool absent=false;
if(female.grade!=-){
printf("%s %s\n",female.name,female.ID);
}
else{
absent=true;
printf("Absent\n");
}
if(male.grade!=INF){
printf("%s %s\n",male.name,male.ID);
}
else{
absent=true;
printf("Absent\n");
}
if(absent){
printf("NA\n");
}
else{
printf("%d\n",female.grade-male.grade);
} return ;
}
PAT甲题题解-1036. Boys vs Girls (25)-找最大最小,大水题的更多相关文章
- PAT (Advanced Level) Practice 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 分)(简单题)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- PAT甲级:1036 Boys vs Girls (25分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- PAT 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- 1036 Boys vs Girls (25分)(水)
1036 Boys vs Girls (25分) This time you are asked to tell the difference between the lowest grade o ...
- PAT (Advanced Level) 1036. Boys vs Girls (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT Advanced 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 分)
题意: 输入一个正整数N(题干没指出范围,默认1e5可以AC),接下来输入N行数据,每行包括一名学生的姓名,性别,学号和分数.输出三行,分别为最高分女性学生的姓名和学号,最低分男性学生的姓名和学号,前 ...
- PAT 1036 Boys vs Girls (25分) 比大小而已
题目 This time you are asked to tell the difference between the lowest grade of all the male students ...
随机推荐
- sysbench压力测试工具安装及使用
使用sysbench指定连接的时候不需要写上mysql-socket参数 如果自己使用sysbench来测试mysql性能的话,建议使用源码编译比较好,版本为0.4版本. 步骤是: .yum inst ...
- Windows Phone 8 获取与监听网络连接状态(转)
原文地址:http://www.cnblogs.com/sonic1abc/archive/2013/04/02/2995196.html 现在的只能手机对网络的依赖程度都很高,尤其是新闻.微博.音乐 ...
- VS2013自带报表+打印功能
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u010773667/article/details/27540389 经过了VB版机房收费系统的学习 ...
- Netty入门(十)解码分隔符和基于长度的协议
我们需要区分不同帧的首尾,通常需要在结尾设定特定分隔符或者在首部添加长度字段,分别称为分隔符协议和基于长度的协议,本节讲解 Netty 如何解码这些协议. 一.分隔符协议 Netty 附带的解码器可以 ...
- Centos7 Nginx 开机启动
Centos 系统服务脚本目录: 用户(user) 用户登录后才能运行的程序,存在用户(user) /usr/lib/systemd/ 系统(system) 如需要开机没有登陆情况下就能运行的程序,存 ...
- win10怎么更改切换输入法按键 切换输入法与Win7一样(Ctrl + 空格)
找到电脑左下角的“开始"图标,用鼠标右键点击它,在弹出的菜单选项里再用鼠标左键点击“设置”来打开Windows设置. 进入“Windows设置”后再点击“设备” 打开“设备”界面后再点击左边 ...
- 3.3 线程---Handler消息传递机制浅析
Handler的执行流程图: 当我们的子线程想修改Activity中的UI组件时,我们可以新建一个Handler对象,通过这个对象向主线程发送信息;而我们发送的信息会先到主线程的MessageQueu ...
- python生成语谱图
语音的时域分析和频域分析是语音分析的两种重要方法,但是都存在着局限性.时域分析对语音信号的频率特性没有直观的了解,频域特性中又没有语音信号随时间的变化关系.而语谱图综合了时域和频域的优点,明显的显示出 ...
- switchable图片切换
前提: 最近由于项目的需要jquery "switchable图片切换"效果 所以趁着周末有空时间研究下 ,以前工作都依赖于kissy框架,所以也没有综合的写过类似的,如下图所示效 ...
- Kafka设计解析(二十)Apache Flink Kafka consumer
转载自 huxihx,原文链接 Apache Flink Kafka consumer Flink提供了Kafka connector用于消费/生产Apache Kafka topic的数据.Flin ...