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

Re:一次AC水过,贴给初学者

Posted by Tonitech at 2013-01-30 16:53:25 on Problem 1581
In Reply To:一次AC水过,贴给初学者 Posted by:realkingiscoming at 2009-11-04 21:24:59
> #include <iostream>
> using namespace std;
> 
> typedef struct 
> {
> 	char name[30];
> 	int solved;
> 	int ppoint;
> } team;
> 
> team t[100];
> 
> int main()
> {
> 
> 	int index;
> 
> 	int i, j;
> 
> 	int n;
> 	
> 	cin>>n;
> 
> 	int sub[4];
> 
> 	int time[4];
> 
> 	int minppoint = 9999999;
> 
> 	int maxsolved = -1;
> 
> 	for(i=0; i<n; i++)
> 	{
> 		cin>>t[i].name;
> 
> 		t[i].solved = 0;
> 		t[i].ppoint = 0;
> 
> 		for(j=0; j<4; j++)
> 		{
> 			cin>>sub[j]>>time[j];
> 			
> 			if(time[j] != 0)
> 			{
> 				t[i].solved++;
> 				t[i].ppoint += (20 * (sub[j] - 1) + time[j]);
> 			}
> 
> 		}//end of 4 problems
> 
> 		if(t[i].solved == maxsolved)
> 		{
> 			if(t[i].ppoint < minppoint)
> 			{
> 				minppoint = t[i].ppoint;
> 				maxsolved = t[i].solved;
> 				index = i;
> 			}
> 		}
> 		else if(t[i].solved > maxsolved)
> 		{
> 			minppoint = t[i].ppoint;
> 			maxsolved = t[i].solved;
> 			index = i;
> 		}
> 	}//end of n teams
> 
> 	cout<<t[index].name<<" "<<t[index].solved<<" "<<t[index].ppoint<<endl;
> 
> 	return 0;
> }
你这代码重复了看到吗?Don't Repeat Yourself!还好意思说水过。。。

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