A1036
输入n行不同学生的name性别id和成绩,输出成绩最高的女生名字和id,成绩最低的男生名字和id求出二者的差
如果有性别缺少,输出Absent并在结果行输出NA
注意变量不要搞混,可以用结构体……不过似乎没有太大必要性
#include <cstdio>
#include <string.h>
int main(){
int mgrade=,fgrade=-,grade,n;
char name[],mname[],fname[],gender,
gen1='n',gen2='n',id[],fid[],mid[];
scanf("%d",&n);
while(n--){
scanf("%s %c %s %d",&name,&gender,&id,&grade);
if(gender=='M'&&grade<mgrade){
strcpy(mname,name);
gen1=gender;
strcpy(mid,id);
mgrade=grade;
}
if(gender=='F'&&grade>fgrade){
strcpy(fname,name);
gen2=gender;
strcpy(fid,id);
fgrade=grade;
}
}
if(gen1=='n'&&gen2=='F'){
printf("%s %s\nAbsent\nNA",fname,fid);
}
else if(gen2=='n'&&gen1=='M'){
printf("Absent\n%s %s\nNA",mname,mid);
}
else{
printf("%s %s\n", fname,fid);
printf("%s %s\n", mname,mid);
printf("%d", fgrade-mgrade);
}
return ;
}
A1036的更多相关文章
- A1036. Boys vs Girls
This time you are asked to tell the difference between the lowest grade of all the male students and ...
- PAT A1036 Boys vs Girls(25)
AC代码 #include <cstdio> #include <algorithm> using namespace std; const int max_n = 11000 ...
- PAT甲级——A1036 Boys vs Girls
This time you are asked to tell the difference between the lowest grade of all the male students and ...
- PAT/查找元素习题集
B1004. 成绩排名 (20) Description: 读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. Input: 每个测试输入包含1个测试用例,格式为: 第1行: ...
- 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...
- PAT题目AC汇总(待补全)
题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...
随机推荐
- nohup后台运行
1.信息输出 nohup java -jar xxxx.jar & 2.信息不输出 nohup java -jar xxxx.jar >/dev/null 2>&1 &am ...
- flask-profiler, 监视端点调用并尝试进行某些分析的Flask 事件探查器
源代码名称:flask-profiler 源代码网址:http://www.github.com/muatik/flask-profiler flask-profiler源代码文档 flask-pro ...
- Java ——运算符
本节重点思维导图 递增递减 前缀自增自减法(++a,--a): 先进行自增.减运算,再进行表达式运算 后缀自增自减法(a++,a--): 先进行表达式运算,再进行自增.减运算 例[1]: int a ...
- 【MM系列】SAP PO增强BADI
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP PO增强BADI 前言部 ...
- 【Qt开发】解决Qt程序在Linux下无法输入中文的办法
解决Qt程序在Linux下无法输入中文的办法 一位网友问我如何在Linux的Qt的应用程序中输入中文,我一开始觉得不是什么问题,但是后面自己尝试了一下还真不行.不仅是Qt制作的应用程序,就连Qt Cr ...
- [LeetCode] 1092. Shortest Common Supersequence
LeetCode刷题记录 传送门 Description Given two strings str1 and str2, return the shortest string that has bo ...
- AcWing 875. 快速幂
题目链接:https://www.acwing.com/problem/content/description/877/ 快速幂模板题,计算ab mod p 的值,a,b,p大概1e9左右,可以快速计 ...
- Square HDU 1518 搜索
Square HDU 1518 搜索 题意 原题链接 给你一定若干个木棒,让你使用它们组成一个四边形,要求这些木棒必须全部使用. 解题思路 木棒有多种组合方式,使用搜索来进行寻找,这里需要进行优化,不 ...
- P1969积木大赛
这是2018与2013提高组的真题,可怕,,原题出了两年,是个纯模拟. 读完题后就想写一个朴素的模拟,先遍历层数,再把达到层数的宽度#存起来,再判断是否连续,如果不连续ans++,然后每一次循环都要初 ...
- Centos7 yum安装LNMP
1.Centos7系统库中默认是没有nginx的rpn包的,所以我们需要先更新下rpm依赖库 (1):使用yum安装nginx,安装nginx库 rpm -Uvh http://nginx.org/p ...