PATA 1036. Boys vs Girls (25), pata1036

Source: Internet
Author: User

PATA 1036. Boys vs Girls (25), pata1036

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, input grade, boy count, girl count, lowest male score, highest female score
    char nam [15], gend, id [15]; // input information
    char name_m [15], id_m [15], name_f [15], id_f [15]; // Save the personal information of the lowest male, and the personal information of the highest female
    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;
} 

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.