zoukankan      html  css  js  c++  java
  • 1036 Boys vs Girls (25分)

     1 #include <iostream>
     2 #include <cstdio>
     3 using namespace std;
     4 struct node
     5 {
     6     char name[20];
     7     char gender;
     8     char id[20];
     9     int grade;
    10 };
    11 int main()
    12 {
    13     int k;
    14     cin >> k;
    15     struct node temp,p1,p2; //p1存M最小,p2存F最大
    16     p1.grade = 101;
    17     p2.grade = -1;
    18     while(k--)
    19     {
    20         scanf("%s %c %s %d",temp.name, &temp.gender, temp.id, &temp.grade);
    21         if(temp.gender == 'M' && temp.grade < p1.grade)
    22             p1 = temp;
    23         if(temp.gender == 'F' && temp.grade > p2.grade)
    24             p2 = temp;
    25     }
    26         if( p2.grade != -1)     printf("%s %s
    ",p2.name, p2.id);
    27             else   printf("Absent
    ");
    28         if( p1.grade != 101)    printf("%s %s
    ",p1.name, p1.id);
    29             else    printf("Absent
    ");
    30         if( p1.grade != 101 &&  p2.grade != -1)
    31             printf("%d",p2.grade-p1.grade);
    32             else    printf("NA");
    33     return 0;
    34 }
  • 相关阅读:
    jq insertBefore 的返回值
    微信公众号-定位之地址逆解析&导航
    微信JS-SDK
    Vue
    ES6-函数的扩展
    ES6-数组的扩展
    JSP
    JS
    HTML+CSS
    jdbc操作数据库
  • 原文地址:https://www.cnblogs.com/2020R/p/13171574.html
Copyright © 2011-2022 走看看