第一个点过不去……跪了
  • 板块P1786 帮贡排序
  • 楼主AD_39
  • 当前回复1
  • 已保存回复1
  • 发布时间2020/5/8 21:43
  • 上次更新2023/11/7 02:50:57
查看原帖
第一个点过不去……跪了
264795
AD_39楼主2020/5/8 21:43

只有第一题不过,显示输出为空

Wrong Answer. wrong answer On line 1 column 1, read (ASCII 32), expected D.

之后强行输出"DrangonflyKang BangZhu"然后发现等级输出成了0

Wrong Answer. wrong answer On line 1 column 23, read 0, expected 6.

之后又强行输出"DrangonflyKang BangZhu 66",第二行副帮主又出现了相同的问题

Wrong Answer. wrong answer On line 2 column 1, read (ASCII 32), expected R.

推测是输入就没输入进去,但是其他组全过了 代码如下

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct {
	char name[35];
	int position;
	int contrubution;
	int level;
	int rank;
}member;

char pos[5][20] = {"HuFa","ZhangLao","TangZhu","JingYing","BangZhong" };
member guild[120];
int sum[5] = { 2,4,7,25,100 };
int memberNum = 0;

char constPos[2][20] = { "BangZhu","FuBangZhu" };
member constMember[3];

void initGuild(void) {
	scanf("%d", &memberNum);
	int top = 1;
	for (int i = 0; i < memberNum - 3; i++) {
		char tempPosition[20];
		char tempName[35];
		int tempContrubution;
		int tempLevel;
		scanf("%s %s %d %d", &tempName, &tempPosition, &tempContrubution, &tempLevel);
		if (strcmp(tempPosition, constPos[0]) == 0) {
			strcpy(constMember[0].name, tempName);
			constMember[0].position = 0;
			constMember[0].level = tempLevel;
			i--;
		}
		else if (strcmp(tempPosition, constPos[1]) == 0) {
			strcpy(constMember[top].name, tempName);
			constMember[top].position = 1;
			constMember[top].level = tempLevel;
			top++;
			i--;
		}
		else {
			for (int j = 0; j < 5; j++) {
				if (strcmp(tempPosition, pos[j]) == 0) {
					strcpy(guild[i].name, tempName);
					guild[i].position = j;
					guild[i].level = tempLevel;
					guild[i].contrubution = tempContrubution;
					guild[i].rank = i;
				}
			}
		}
	}
}
int compar1(const void* p1, const void* p2) {
	member* a1 = (member*)p1;
	member* a2 = (member*)p2;
	return a2->contrubution - a1->contrubution;
}
void arrange(void) {
	int top = 0, flag = 0;
	for (int i = 0; i < 5 && flag == 0; i++) {
		for (int j = 0; j < sum[i] && flag == 0; j++) {
			guild[top++].position = i;
			if (top == memberNum - 3) {
				flag = 1;
			}
		}
	}
}
int compar2(const void* p1, const void* p2) {
	member* a1 = (member*)p1;
	member* a2 = (member*)p2;
	if (a1->position != a2->position) {
		return a1->position - a2->position;
	}
	else if (a1->level != a2->level) {
		return a2->level - a1->level;
	}
	else {
		return a1->rank - a2->rank;
	}
}
void output(void) {
	printf("%s %s %d\n", constMember[0].name, constPos[constMember[0].position], constMember[0].level);
	if (constMember[1].level >= constMember[2].level) {
		printf("%s %s %d\n", constMember[1].name, constPos[constMember[1].position], constMember[1].level);
		printf("%s %s %d\n", constMember[2].name, constPos[constMember[2].position], constMember[2].level);
	}
	else {
		printf("%s %s %d\n", constMember[2].name, constPos[constMember[2].position], constMember[2].level);
		printf("%s %s %d\n", constMember[1].name, constPos[constMember[1].position], constMember[1].level);
	}
	for (int i = 0; i < memberNum - 3; i++) {
		printf("%s %s %d\n", guild[i].name, pos[guild[i].position], guild[i].level);
	}
}
int main(void) {
	initGuild();
	qsort(guild, memberNum - 3, sizeof(member), compar1);
	arrange();
	qsort(guild, memberNum - 3, sizeof(member), compar2);
	output();
	return 0;
}
2020/5/8 21:43
加载中...