zju pat 1036

zju pat 1036
//1036
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
typedef struct DATA
{
    char name[20];
    char gender;
    char ID[20];
    int grade;
};
DATA data;
DATA femal_highest;
DATA male_lowest;

int main()
{
    int N,i,j,no_count;
    bool easy_flag;
    while(scanf("%d",&N)!=EOF)
    {
        femal_highest.grade = -1;
        male_lowest.grade = 101;
        for(i =0;i<N;i++)
        {
            scanf("%s %c %s %d",data.name,&data.gender,data.ID,&data.grade);
            if(data.gender == F)
            {
                if(data.grade > femal_highest.grade)
                {
                    strcpy(femal_highest.name,data.name);
                    strcpy(femal_highest.ID,data.ID);
                    femal_highest.grade = data.grade;
                }
            }
            else
            {
                if(data.grade < male_lowest.grade)
                {
                    strcpy(male_lowest.name,data.name);
                    strcpy(male_lowest.ID,data.ID);
                    male_lowest.grade = data.grade;
                }
            }
        }
        if(femal_highest.grade !=-1)
        {
            printf("%s %s\n",femal_highest.name,femal_highest.ID);
        }
        else
        {
            printf("Absent\n");
        }
        if(male_lowest.grade != 101)
        {
            printf("%s %s\n",male_lowest.name,male_lowest.ID);
        }
        else
        {
            printf("Absent\n");
        }
        if(femal_highest.grade!=-1 && male_lowest.grade !=101)
            printf("%d\n",femal_highest.grade - male_lowest.grade);
        else
            printf("NA\n");
    }
    return 0;
}
zju pat 1036

zju pat 1036

上一篇:shell变量的截取总结


下一篇:思维导图–云笔记测试的利器(转)