WA,why?
查看原帖
WA,why?
217680
Anonymous_404楼主2022/8/24 18:11
#include<stdio.h>
struct Contestnant
{
	char name;
	int score[5];
	int score_total = 0;
	int rank_upper = 1;
	int rank_lower = 1;
}cont[500];

int main(void)
{
	int num, score_upper[500];
	scanf("%d", &num);
	
	for (int i = 0; i < num; i++) {
		scanf("%s", &cont[i].name);
		for (int j = 0; j < 5; j++) {
			scanf("%d", &cont[i].score[j]);
			}
		}
		
	for (int i = 0; i < num; i++) {
		for (int j = 0; j < 5; j++) {
			cont[i].score_total+=cont[i].score[j];
			}
		}
		
	for (int i = 0; i < num; i++) {
		score_upper[i] = cont[i].score_total+500;
		}
		
	for (int i = 0; i < num; i++) {
		for (int j = 0; j < num; j++) {
			if (i == j) continue;
			if (score_upper[i] < cont[j].score_total) {
				cont[i].rank_upper++;
				}
			if (score_upper[i] == cont[j].score_total && cont[i].name > cont[j].name) {
				cont[i].rank_upper++;
				}
			if (score_upper[j] > cont[i].score_total) {
				cont[i].rank_lower++;
				}
			if (score_upper[j] == cont[i].score_total && cont[i].name > cont[j].name) {
				cont[i].rank_lower++;
				}
			}
		}
	
	for (int i = 0; i < num; i++) {
		printf("%d %d\n", cont[i].rank_upper, cont[i].rank_lower);
		}
	return 0;
}
2022/8/24 18:11
加载中...