题意:给出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)-找最大最小,大水题的更多相关文章

  1. 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 ...

  2. PAT 甲级 1036 Boys vs Girls (25 分)(简单题)

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

  3. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  4. PAT 1036 Boys vs Girls (25 分)

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

  5. 1036 Boys vs Girls (25分)(水)

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

  6. PAT (Advanced Level) 1036. Boys vs Girls (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  7. 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 ...

  8. 【PAT甲级】1036 Boys vs Girls (25 分)

    题意: 输入一个正整数N(题干没指出范围,默认1e5可以AC),接下来输入N行数据,每行包括一名学生的姓名,性别,学号和分数.输出三行,分别为最高分女性学生的姓名和学号,最低分男性学生的姓名和学号,前 ...

  9. PAT 1036 Boys vs Girls (25分) 比大小而已

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

随机推荐

  1. Github的一般用法

    写了这么多年代码,源代码版本管理从一开始的没有后来的VSS,CVS,到现在一直在使用的SVN,但这些都是集中式的版本管理. 而分布式的版本管理还没有使用过. 今天看了看Github,研究一下怎么使用G ...

  2. IOS和安卓不同浏览器常见bug

    一.IOS自带safari浏览器 1.safari不支持fixed.input输入框 iOS下的 Fixed + Input 调用键盘的时候fixed无效问题 拖动页面时 header 和 foote ...

  3. 《JavaScript高级程序设计》读书笔记--ECMAScript中所有函数的参数都是按值传递的

    ECMAScript中所有函数的参数都是按值传递的.也就是说把函数外部的值复制给函数内部的参数(内部参数的值的修改不影响实参的值). 基本类型变量的复制: 基本类型变量的复制,仅仅是值复制,num1和 ...

  4. Linux备份压缩命令

    gzip 命令 把/home/chenjialins目录下的familyA目录下所有文件压缩成.gz文件cd /home/chenjialinstar -cvf /home/chenjialins/f ...

  5. WorldWind源码剖析系列:枚举类型

    PluginSDK中的枚举型主要有以下这些: public enum AltitudeMode//高度模式枚举 { ClampedToGround,//强制到地面模式 RelativeToGround ...

  6. kubernetes 的wen pod 无法连接 mysql 的pod

    1.分析 查看源代码 既然无法建立连接,那先看下是如何建立连接的.登录到myweb的docker容器里面,查看index.jsp文件,主要内容如下: Class.forName("com.m ...

  7. jquery获取具有多个类class的标签内容

    var tag = $('div.firstClassName.secondClassName.thirdClassName'); 注意空格

  8. VBA删除 语法

    Option Explicit '清空数据  Private Sub CommandButton1_Click() Dim qknum As Integer  '选择是或者否 来确认删除数据 '中对话 ...

  9. odoo之显示前端,数据,可选择

    def create(self,cr,uid,vals,context=None): if context is None: context ={} if vals.get('name','/')== ...

  10. 安装Jenkins服务

    1.下载Jenkins 下载地址:https://jenkins.io/download/ 选择rpm包 2.启动服务 [root@node1 ~]# rpm -ivh jenkins-2.138.3 ...