1032 挖掘机技术哪家强(C语言)

设计思路:
  • 利用数组存储成绩,找最大值输出
编译器:C (gcc)
#include 

int main()
{
    int n, school, score, max = 0;
    int schools[100000] = {0}, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d", &school, &score);
        schools[school - 1] += score;
    }
    for(i = 0; i < n; i++){
        if(schools[i] > schools[max]){
            max = i;
        }
    }
    printf("%d %d\n", max + 1, schools[max]);
    return 0;
}

你可能感兴趣的:(PAT,乙级)