PATA 1036. Boys vs Girls (25)

2018-02-14 11:36:44来源:cnblogs.com作者:zengq人点击

分享
第七城市

https://www.patest.cn/contests/pat-a-practise/1036

#include <bits/stdc++.h>using namespace std;int main(){    int n,i,gra,boyc = 0,girlc = 0,boymin = 101,girlmax = -1;//n,输入成绩,男生计数,女生计数,男最低分,女最高分    char nam[15],gend,id[15]; //输入信息    char name_m[15],id_m[15],name_f[15],id_f[15];//保存最低分男的个人信息,最高分女的个人信息    scanf("%d",&n);    for(i = 0;i < n; i++)    {        scanf("%s %c %s %d",nam,&gend,id,&gra);        if(gend == 'M')    {            boyc++;            if(gra < boymin){                boymin = gra;                strcpy(name_m,nam);                strcpy(id_m,id);            }                    }        else {            girlc++;            if(gra > girlmax){                girlmax = gra;                strcpy(name_f,nam);                strcpy(id_f,id);            }        }    }    if(girlc == 0){        printf("Absent/n");    }    else{        printf("%s %s/n",name_f,id_f);    }    if(boyc == 0){        printf("Absent/n");    }    else{        printf("%s %s/n",name_m,id_m);    }    if(girlc == 0||boyc == 0){        printf("NA");    }    else{        printf("%d",girlmax-boymin);    }    return 0;}
第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台