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 ...
随机推荐
- laravel上传图片报错
在laravel的上传图片代码文件中路径如下: vendor\stevenyangecho\laravel-u-editor\src\Uploader\Upload.php第131行有一句代码错误$r ...
- 3130: [Sdoi2013]费用流
Description Alice和Bob在图论课程上学习了最大流和最小费用最大流的相关知识. 最大流问题:给定一张有向图表示运输网络,一个源点S和一个汇点T,每条边都有最大流量.一个合法的网络流方案 ...
- bip32
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki RECENT CHANGES: (16 Apr 2013) Added p ...
- java中线程的几种状态和停止线程的方法
1.线程的状态图 需要注意的是:线程调用start方法是使得线程到达就绪状态而不是运行状态 2.停止线程的两种方法 1)自然停止:线程体自然执行完毕 2)外部干涉:通过线程体标识 1.线程类中定义线程 ...
- 降阶法计算行列式方法有个地方有Bug(原文也已更正,此为更正后部分)
今天用此函数做方程求解时发现有误,特此更正: /// <summary> /// 降阶法计算行列式 /// </summary> /// <param name=&quo ...
- Go语言安全编码规范-翻译(分享转发)
Go语言安全编码规范-翻译 本文翻译原文由:blood_zer0.Lingfighting完成 如果翻译的有问题:联系我(Lzero2012).匆忙翻译肯定会有很多错误,欢迎大家一起讨论Go语言安全能 ...
- XAMPP、PHPstorm和PHPcharm和Windows环境下Python搭建+暴力破解
XAMPP的安装和使用 一.什么是XAMPP? XAMPP是最流行的PHP开发环境. XAMPP是完全免费且易于安装的Apache发行版,其中包含Apache.MariaDB.PHP和Perl. 类似 ...
- WPF编程,获取句柄将外部程序嵌入到WPF界面。
原文:WPF编程,获取句柄将外部程序嵌入到WPF界面. 版权声明:我不生产代码,我只是代码的搬运工. https://blog.csdn.net/qq_43307934/article/details ...
- 2017战略No.2:开始电子化记账
一.懒散的4年 大学毕业后,就没有怎么记账了. 自己花的钱,心里有个大概,但是不能算得很具体. 比如说,2016年,又没有攒几个钱,心里多少有点压抑. 大脑去算账,只能算房租吃饭等金额较大的开销,更多 ...
- POJ1807&&1276
DP专题下的背包专题 其实就是PJ的那些东西了 主流的背包有三种:01背包,完全背包和多重背包 其中01背包和完全背包的转移就比较经典了,而多重背包也是在前两者基础上演变一下即可 1837 题意:有一 ...