This article is participating in the nuggets team number online activity, click to see the dachang spring recruiting positions

1. Title Description

Read n (>0) students’ names, student numbers and grades, output the names and numbers of the students with the highest and lowest grades respectively.

Input format: Each test input contains 1 test case in the format of

Line 1: positive integer n Line 2: first student’s name Student number grade Line 3: second student’s name student number grade… . . Line N +1: Name of the NTH student Student NUMBER grade where both the name and student number are strings of up to 10 characters and the grade is an integer between 0 and 100. It is guaranteed that no two students have the same grade in a set of test cases.

Output format: Output 2 lines for each test case, the first line is the name and student number of the highest student, the second line is the name and student number of the lowest student, with 1 space between the strings.

Example: 3 Joe Math990112 89 Mike CS991301 100 Mary EE990830 95 Example: Mike CS991301 Joe Math990112

Second, train of thought analysis

I came up with an array of characters to store names, and an array of integers to store fractions for student numbers and notice, notice, notice, we’re going to use an 11-bit array for names and student numbers, because we have a ‘/0’😂 at the end

AC code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    char name[n][11],num[n][11];
    int score[n];
    int iMax,iMin,scoreMax=0,scoreMin=100;
    for(i=0; i<n; i++) { cin>>name[i]>>num[i]>>score[i];if(score[i]>scoreMax)
                scoreMax=score[i],iMax=i;
            if(score[i]<scoreMin)
                scoreMin=score[i],iMin=i;
    }
    cout<<name[iMax]<<' '<<num[iMax]<<endl;
    cout<<name[iMin]<<' '<<num[iMin];
    return 0;
}
Copy the code

Four,

Problem 12, keep up the good work 😁