全部WA,样例无误
查看原帖
全部WA,样例无误
403749
wph2333楼主2020/11/23 00:15
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
typedef struct student {
    char name[20] = { 0 };
    int score1;
    int score2;
    char manager;
    char west;
    int paper;
}student;

int main()
{
    int n;
    int i, j, k;
    char c;
    struct student stu[100];
    int total = 0, sum[100] = { 0 };
    int max;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        j = 0;
        c = getchar();
        while ((c = getchar()) != ' ') {
            stu[i].name[j] = c;
            j++;
        }
        scanf("%d%d", &stu[i].score1, &stu[i].score2);
        while ((stu[i].manager = getchar()) == ' ');
        while ((stu[i].west = getchar()) == ' ');
        scanf("%d", &stu[i].paper);
    }
    for (i = 0; i < n; i++) {
        if (stu[i].score1 > 80 && stu[i].paper != 0) {
            sum[i] += 8000;
            total += 8000;
        }
        if (stu[i].score1 > 85 && stu[i].score2 > 80) {
            sum[i] += 4000;
            total += 4000;
        }
        if (stu[i].score1 > 90) {
            sum[i] += 2000;
            total += 2000;
        }
        if (stu[i].score1 > 85 && stu[i].west == 'Y') {
            sum[i] += 1000;
            total += 1000;
        }
        if (stu[i].score2 > 80 && stu[i].manager == 'Y') {
            sum[i] += 850;
            total += 850;
        }
    }
    max = 0;
    for (i = 1; i < n; i++) {
        if (sum[i] > sum[max]) {
            max = i;
        }
    }
    i = 0;
    while (stu[max].name[i] != 0) {
        printf("%c", stu[max].name[i]);
        i++;
    }
    printf("\n");
    printf("%d\n%d", sum[max], total);
}

输入输出字符串的时候有点累赘,但这是改过好多版之后没办法了,结果还是WA,枯了。。

2020/11/23 00:15
加载中...