#include <stdio.h>

struct student {
    int id;    /* 学籍番号 */
    int eng;   /* 英語 */
    int math;  /* 数学 */
    int sci;   /* 理科 */
};

#define N 3

int main() {

    int i, j;

    struct student s[N] = {
        {17001, 60, 100, 20},
        {17002, 90, 40, 80},
        {17003, 20, 30, 50}
    };

    struct student tmp;

    int total1, total2;

    /* 合計点で昇順ソート */
    for(i = 1; i < N; i++) {
        for(j = 0; j < N - i; j++) {

            total1 = s[j].eng + s[j].math + s[j].sci;
            total2 = s[j+1].eng + s[j+1].math + s[j+1].sci;

            if(total1 > total2) {
                tmp = s[j];
                s[j] = s[j+1];
                s[j+1] = tmp;
            }
        }
    }

    /* 表示 */
    for(i = 0; i < N; i++) {

        int total = s[i].eng + s[i].math + s[i].sci;

        printf("学籍番号:%d 英語:%d 数学:%d 理科:%d 合計:%d\n",
               s[i].id, s[i].eng, s[i].math, s[i].sci, total);
    }

    return 0;
}