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 ( ...
随机推荐
- eclipse和myeclipse怎么在项目中查找指定代码?https://www.jb51.net/softjc/554889.html
有的童鞋,想eclipse和myeclipse整个项目中查找指定代码,由于补经常使用,可能会补熟悉.如果要去掉项目中所有的某个代码的话,找不到是灰常麻烦的,下面就简单说下怎么查找,希望对需要的人有用. ...
- Chapter03 第三节 浮点数
3.3 浮点数 3.3.1 浮点数的表示 常规表示:12.34.0.01.8.0 E表示: 2.5e+8(2.5 10^8).7E6(7.0 10^6) (e大小写随意) (e+x或者E-x表示小数点 ...
- ipad已停用 连接itunes怎么办
问题描述: ipad 开机密码多次输入出错后,提示 ipad已停用 连接itunes 解决方法: 参考: https://jingyan.baidu.com/article/fb48e8bee9ef4 ...
- linux--vm安装
网络排错图解 https://www.linuxidc.com/Linux/2017-03/141863.htm net模式 https://www.linuxidc.com/Linux/2017-0 ...
- python函数-内置函数
官方文档[http://www.cnblogs.com/dingkailinux/p/7954484.html] 1.int()函数,表示整形,如 1,2,-1,-2. 2.float()函数,表示浮 ...
- Python 内置函数super
super()函数是用于调用父类/超类的一个方法 super是用来解决多重继承问题的,直接用类名调用父类方法在使用单继承的时候没有问题,但是如果使用多继承,会涉及到查找顺序(MRO),重复调用(钻石继 ...
- Windows消息理解(系统消息队列,进程消息队列,非队列消息)
// ====================Windows消息分类==========================在Windows中,消息分为以下三类:标准消息——除WM_COMMAND之外,所 ...
- 计算机体系结构总结_Pipeline
Textbook:<计算机组成与设计——硬件/软件接口> HI<计算机体系结构——量化研究方法> QR 在前面一节里我们有了一块简单的RISC CPU,包括 ...
- 数组和datatable间的相互转换[C#]
byte[] LogMsgByte = null; DataTable dtMessageInfo = new DataTable(); //将datatable转换为数组 dtMessageInfo ...
- mysql,oracle,sql server数据库默认的端口号,端口号可以为负数吗?以及常用协议所对应的缺省端口号
mysql,oracle,sql server数据库默认的端口号? mysql:3306 Oracle:1521 sql server:1433 端口号可以为负吗? 不可以,端口号都有范围的,0~65 ...