Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

C111的代码,高手们帮我简化一下

Posted by C111 at 2012-03-27 21:30:14 on Problem 1581
#include<stdio.h>
int main()
{
	int i,j,maxd,mine;
	int d[4]={0,0,0,0};
	int e[4]={0,0,0,0};
	 typedef struct ppp
	{
		char a[4][20];
		int b[4][4];
		int c[4][4];
	}pp;
	pp p;
	scanf("%d",&i);
	for(i=0;i<4;i++)
	{
		scanf("%s",p.a[i]);
		scanf("%d",&p.b[i][0]);
		scanf("%d",&p.c[i][0]);
		scanf("%d",&p.b[i][1]);
		scanf("%d",&p.c[i][1]);
		scanf("%d",&p.b[i][2]);
		scanf("%d",&p.c[i][2]);
		scanf("%d",&p.b[i][3]);
		scanf("%d",&p.c[i][3]);

	}
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			if(p.c[i][j]>0)
			{
				d[i]++;
				e[i]=e[i]+(p.b[i][j]-1)*20+p.c[i][j];
			}
		}
	}
	maxd=d[0];
	mine=e[0];
	for(i=0;i<4;i++)
	{  
		if(maxd<d[i])
		{
			maxd=d[i];
			mine=e[i];
		}
		if(maxd==d[i]&&e[i]<mine)
		{
            maxd=d[i];
			mine=e[i];
		}
	
	}
	for(i=0;i<4;i++)
	{
		if(d[i]==maxd&&e[i]==mine)
		{
			printf("%s %d %d\n",p.a[i],d[i],e[i]);
		}
	}
	return 0;

}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator