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

知道为啥错了,测试案例不够充分,需要每次对stu_evil和stu_kind赋0

Posted by wzp_moon at 2015-08-25 09:58:42 on Problem 1547
In Reply To:Re:为什么Wrong answer?请各位大牛帮我看看 Posted by:wzp_moon at 2015-08-25 09:21:56
#include <stdio.h>

#define LEN 10

typedef struct{
	short len;
	short wide;
	short high;
	char stu_name[LEN];
}STUDENT;

int main(void)
{
	int n,i,j,k;
	STUDENT stu[LEN];
	int stu_kind;
	int stu_evil;
	int tmp_v;
	int v;
	scanf("%d",&n);
	while(n != -1)
	{
		tmp_v = v = 0;
		stu_evil = stu_kind = 0;

		for (i = 0;i < n;i++)
		{
			scanf("%d %d %d %s",&stu[i].len,&stu[i].wide,&stu[i].high,stu[i].stu_name);
		}
		for (j = 0;j < n;j++)
		{
			tmp_v = stu[j].len * stu[j].wide * stu[j].high;
			if(tmp_v > v)
			{
				v = tmp_v;
				stu_evil = j;
			}
		}
		tmp_v = 0;
		v = stu[0].len * stu[0].wide * stu[0].high;
		stu_kind = 0;
		for (k = 1;k < n;k++)
		{
			tmp_v = stu[k].len * stu[k].wide * stu[k].high;
			if (tmp_v < v)
			{
				v = tmp_v;
				stu_kind = k;
			}
		}
		printf("%s took clay from %s.\n",stu[stu_evil].stu_name,stu[stu_kind].stu_name);
		scanf("%d",&n);
	}

	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