3477. Sort Students

Easy基本数据类型函数普通指针结构体排序

时间限制:1000 ms

内存限制:256 MiB

题面

/***************************************************************/
/*                                                             */
/*  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;
} 

样例

输入

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

输出

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