题意:给出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. 微信支付回调,XXE攻击漏洞防止方法

    最近微信支付回调发现的XXE攻击漏洞(什么是XXE攻击,度娘.bing去搜,一搜一大把),收到通知后即检查代码, 微信给的解决方法是如果你使用的是: XmlDocument: XmlDocument ...

  2. 开源作业调度框架 - Quartz.NET - 实战使用2

    纠正第一篇文章的一个错误代码. 下面是错误代码,这样并不能得知系统中是否已经存在该JobId //实例化一个作业Key对象,用于获取作业对象或判断是否存在作业时使用. JobKey jobKey = ...

  3. 【Ansible 文档】【译文】常见问题

    http://docs.ansible.com/ansible/latest/faq.html 如何为一个task或者整个Playbook设置PATH或者任意其他环境变量? 通过environment ...

  4. 12.SolrCloud原理

    转载自http://blog.csdn.net/u011026968/article/details/50336709 内容涉及:SolrCloud的基础知识.架构.索引创建和更新.查询.故障恢复.负 ...

  5. Windows连接Linux虚拟机里面的Docker容器

    一.Windows.Linux虚拟机.docker关系图 如果此时在Windows宿主机中pingDocker容器是ping不同的,因为在宿主机上没有通往172.17.0.0/24网络的路由,宿主机会 ...

  6. Azkaban学习之路 (二)Azkaban的安装

    安装过程 1.软件介绍 Azkaban Web 服务器:azkaban-web-server-2.5.0.tar.gz Azkaban Excutor 执行服务器:azkaban-executor-s ...

  7. debian文本配置网络备忘:/etc/network/interfaces

    我装了wheezy有gnome3,xfce4: 郁闷的是,不论在gnome还是xfce4中 我都无法图形登录或者切换用户到root: 而且我无法在普通用户下图形修改网络配置: 我也搜索不到启用root ...

  8. WorldWind源码剖析系列:可渲染对象列表类RenderableObjectList

    可渲染对象列表类RenderableObjectList用来存储与一个星球体相关联的全部的可渲染对象,继承自可渲染对象类RenderableObject.RenderableObjectList的类图 ...

  9. opencv7-ml之统计模型

    在opencv的ml模块中有个统计模型类,而其他的比如朴素贝叶斯分类器.knn.svm等等其他模型都是基于该模型上派生出来的.所以先介绍下该模型. 该类的定义在文件"opencv\sourc ...

  10. jqgrid 配置行号及行号的宽度

    有时,我们想把jqgrid的行号按指定的宽度显示出来,如何实现? 通过 rownumbers:true  设置启用行号 通过 rownumWidth 配置行号列的宽度 $("#jqGrid& ...