2022级统计计算机双学位《程序设计原理与C语言》上机作业

1056. Sort Students

单点时限: 1.0 sec

内存限制: 256 MB

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/

// ********** Specification of STUDENT **********
// No.:  long long  
// Name: char[15]
// Scores: 3 integers (0-100)
//

typedef struct {
    long long num;
    char name[15];
    int score[3];
} STUDENT;


/********** Specification of Input **********/
STUDENT* Input(int n)
/* PreCondition:
     the length of student namelist
   PostCondition:
     an pointer pointed to the array that store information of n students
*/
{ //TODO: your function definition

}

/********** Specification of Sort **********/
void Sort(STUDENT *ps, int n)
/* PreCondition:
       ps points to a Student array with n positive integers
   PostCondition:
       Array pointed by ps is sorted based on their mean scores in descending order.
       If two students have identical mean scores, the order is based on student 
       numbers in ascending order.
*/
{ //TODO: your function definition

}

#include <stdio.h>
#define N 100000

int main() {
    STUDENT* a = NULL;
    int i, n;
    scanf("%d\n", &n);

    a = Input(n);
    Sort(a, n);

    for (i = 0; i < n; i++)
        printf("%lld %s %d %d %d\n", a[i].num, a[i].name,
               a[i].score[0], a[i].score[1], a[i].score[2]);
    return 0;
} 

样例

Input
5
5 you 59 59 59
4 will 58 59 59
3 fail 58 58 59
2 the 58 58 58
1 exam 59 59 59
Output
1 exam 59 59 59
5 you 59 59 59
4 will 58 59 59
3 fail 58 58 59
2 the 58 58 58