7-1 curriculum stats (20 points)

Title:
curriculum design as a team to reply, each group numbered and four members of a unique positive integer represented. Respondent uses the results ranking system, each team will submit a reply transcript after the respondent, the results table lists all the teams ranked from high to low numbers in the order. For example, the maximum score for the table data group No. Group No. 5,2 filed {51,243}, the group ranked No. 5, No. 1 Group # 2, and so on. The final ranking of each team standings respondent submitted in accordance with all groups and reordered, and the smaller the higher the ranking, from high to low ranking is 1,2,3, .... Please help Statistics teacher at the final ranking of each team.

Input format:
input given positive integer N (N≤10) in a row, the number for the group. Then N rows, according to group number i (1≤i≤N) Firstly, the ascending order for each row in the name of the i-th four group members, separated by a space, then the respondent is given a score table group submitted by the N positive integers, separated by a space intermediate, group number corresponding ranking from high to low. Wherein the name is not longer than non-empty string of characters that does not contain blanks 20.
Output format:
, separated by a space of non-increasing order according to the final ranking, the ranking given to each row, and four members of the group corresponding to the output of the name in the input order. If the teams have the same final ranking, then re-export in accordance with the group numbers in ascending order.

Sample input:
. 5
xiaozhao zhangwuji zhaomin zhouzhiruo 2. 5. 4. 3. 1
huangrong guojing Guofu Guoxiang 2. 4. 3. 1. 5
yangguo xiaolongyu limochou laowantong. 5. 4. 3. 1 2
yangkang monianci ouyangxiu zhoubotong 2. 5. 4. 3. 1
yuanchengzhi Qingqing Wenyi gongzhu. 5. 4. 3. 1 2
output sample:
. 1 huangrong guojing Guofu Guoxiang
2 yangguo xiaolongyu limochou laowantong
. 3 xiaozhao zhangwuji zhaomin zhouzhiruo
. 4 yuanchengzhi Qingqing Wenyi gongzhu
. 5 yangkang monianci ouyangxiu zhoubotong

Code:

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#define N 11

typedef struct stu {
	char name1[21];
	char name2[21];
	char name3[21];
	char name4[21];
	int score[N];
	int sc;
}Stu;

int main(void)
{
	Stu s[N];
	char name[21];
	int n;
	scanf("%d", &n);
	int i;
	int j;
	for (i = 1; i <= n; i++)
	{
		scanf("%s %s %s %s", s[i].name1, s[i].name2, s[i].name3, s[i].name4);
		for (j = 1; j <= n; j++)
		{
			scanf("%d", &s[i].score[j]);
		}
	}
	for (i = 1; i <= n; i++)
	{
		s[i].sc = 0;
	}
	for (i = 1; i <= n; i++)
	{
		for(int k = 1;k <= n;k++)
		for (j = 1; j <= n; j++)
		{
			if (s[k].score[j] == i)
			{
				s[i].sc += j;
			}
		}
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j < n ; j++)
		{
			if (s[j].sc > s[j + 1].sc)
			{
				Stu t = s[j];
				s[j] = s[j + 1];
				s[j + 1] = t;
			}
		}
	}
	for (i = 1; i <= n; i++)
	{
		printf("%d %s %s %s %s\n", i, s[i].name1, s[i].name2, s[i].name3, s[i].name4);
	}
	return 0;
}
Published 13 original articles · won praise 11 · views 475

Guess you like

Origin blog.csdn.net/qq_45811966/article/details/103652108
Recommended