输入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的更多相关文章

  1. A1036. Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  2. PAT A1036 Boys vs Girls(25)

    AC代码 #include <cstdio> #include <algorithm> using namespace std; const int max_n = 11000 ...

  3. PAT甲级——A1036 Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  4. PAT/查找元素习题集

    B1004. 成绩排名 (20) Description: 读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. Input: 每个测试输入包含1个测试用例,格式为: 第1行: ...

  5. 1036 Boys vs Girls (25 分)

    1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...

  6. PAT题目AC汇总(待补全)

    题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...

随机推荐

  1. log() exp()函数

    1 对数函数表示法 import numpy as np import math print('输出自然底数e:',math.e) # np表示法 # np.log()是以e为底的自然对数 print ...

  2. c++ 事件回调 java

    #pragma once #ifdef __cplusplus extern "C" { #endif typedef void(*sig_t)(int); int FirstEl ...

  3. cocos2dx基础篇(9) 滑块控件CCControlSlider

    [3.x] (1)去掉 “CC” (2)对象类 CCObject 改为 Ref (3)CCControlEvent 改为强枚举 Control::EventType (4)CCControlEvent ...

  4. spark MLlib矩阵四则运算,线性代数

    1.导包请看我的上一篇博文,maven项目的包 https://www.cnblogs.com/wuzaipei/p/10965680.html 2.denseMatirx 矩阵四则运算如下 版本不同 ...

  5. 一、Zabbix-学习列表

    近期本人在求职,面试了几家,觉得监控是一个很重要的事情,所以决定深入学习一下监控.目前的监控系统有很多,Zabbix是目前应用最广泛的开源监控之一,功能比较完善,所以决定学习一下. 目前将学习zabb ...

  6. C#WebApi自动生成文档

    1.效果图 2.在webApi项目,打开Nuget,搜索WebApiTestClient,安装WebApiTestClient,注意是给HelpPage的 3.打开引入WebApiTestClient ...

  7. windows上Appium安装和使用

    1.Appium安装相关依赖工具: Android Studio或者Android SDK:https://developer.android.com/studio/Appium Desktop: h ...

  8. Linux/Unix下pid文件作用浅析

    转载:http://blog.csdn.net/changli_90/article/details/8911191 在Linux系统的目录/var/run下面一般我们都会看到很多的*.pid文件.而 ...

  9. 搜索专题: HDU1026Ignatius and the Princess I

    Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  10. BZOJ 5317: [Jsoi2018]部落战争

    传送门 写出式子,若存在 $a \in A$,$b \in B$,使得 $b+v=a$,那么此方案会产生冲突 即存在 $a \in A$,$b \in B$,使得 $v=a+(-b)$,设 $C=A+ ...