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

如果有人一个球没扔你的程序好像就不行了

Posted by frkstyc at 2006-03-17 13:35:13 on Problem 1076
In Reply To:样例过了,交上去就WA,谁帮看看 Posted by:crazydo at 2006-03-17 13:32:16
> #include <iostream>
> #include <iomanip>
> 
> using namespace std;
> 
> char Bowler[12];
> int Score[11], Count[11], Kick[11];
> 
> void add(int frame, int score)
> {
> 	Score[frame] += score;
> 	Count[frame]++;
> 	if (frame - 1 >= 1 && Count[frame - 1] < 3)
> 	{
> 		if (Kick[frame - 1] == 10) Score[frame - 1] += score;
> 		Count[frame - 1]++;
> 	}
> 	if (frame - 2 >= 1 && Count[frame - 2] < 3)
> 	{
> 		if (Kick[frame - 2] == 10) Score[frame - 2] += score;
> 		Count[frame - 2]++;
> 	}
> }
> 
> int main()
> {
> 	while (cin >>Bowler)
> 	{
> 		cout <<Bowler;
> 		cout <<setw(14 - strlen(Bowler));
> 		int left = 0, left2 = 0, left3 = 0, out, count = 0;
> 		cin >>left;
> 		while (left >= 0 && left2 >= 0 && left3 >= 0)
> 		{
> 			out = 0;
> 			count++;
> 			if (left == 0)
> 			{
> 				Kick[count] = 10;
> 				add(count, 10);
> 				cout <<'X';
> 				out++;
> 				if (count == 10)
> 				{
> 					cin >>left2;
> 					if (left2 == 0)
> 					{
> 						Kick[count] = 10;
> 						add(count, 10);
> 						cout <<'X';
> 					}
> 					else if (left2 != -1)
> 					{
> 						add(count, 10 - left2);
> 						cout <<10 - left2;
> 					}
> 				}
> 			}
> 			else
> 			{
> 				if (left == 10)
> 				{
> 					add(count, 0);
> 					cout <<'-';
> 				}
> 				else
> 				{
> 					add(count, 10 - left);
> 					cout <<10 - left;
> 				}
> 				out++;
> 				cin >>left2;
> 				if (count == 10)
> 				{
> 					if (left2 == 0)
> 					{
> 						if (left == 0)
> 						{
> 							Kick[count] = 10;
> 							add(count, 10);
> 							cout <<'X';
> 						}
> 						else
> 						{
> 							Kick[count] = 10;
> 							add(count, left);
> 							cout <<'/';
> 						}
> 					}
> 					else
> 					{
> 						add(count, left - left2);
> 						cout <<left - left2;
> 					}
> 				}
> 				else if (left2 != -1)
> 				{
> 					if (left2 == 0)
> 					{
> 						Kick[count] = 10;
> 						add(count, left);
> 						cout <<'/';
> 					}
> 					else
> 					{
> 						Kick[count] = 10 - left2;
> 						add(count, left - left2);
> 						cout <<left - left2;
> 					}
> 					out++;
> 				}
> 			}
> 			if (count == 10 && Kick[count] == 10)
> 			{
> 				cin >>left3;
> 				if (left3 == 0)
> 				{
> 					if (left2 == 0)
> 					{
> 						Kick[count] = 10;
> 						add(count, 10);
> 						cout <<'X';
> 					}
> 					else
> 					{
> 						Kick[count] = 10;
> 						add(count, left2);
> 						cout <<'/';
> 					}
> 				}
> 				else if (left3 != -1)
> 				{
> 					if (left2 == 0)
> 					{
> 						add(count, 10 - left3);
> 						cout <<10 - left3;
> 					}
> 					else
> 					{
> 						add(count, left2 - left3);
> 						cout <<left2 - left3;
> 					}
> 				}
> 			}
> 			if (left >= 0 && left2 >= 0 && left3 >= 0)
> 				cin >>left;
> 			if (left == -1 || left2 == -1 || left3 == -1) 
> 			{
> 				cout <<endl;
> 				cout <<"            ";
> 				int total = 0;
> 				for (int i = 1; i <= count; i++)
> 				{
> 					if (Count[i] < 3) break;
> 					total += Score[i];
> 					cout <<setw(4) <<total;
> 				}
> 				cout <<endl <<endl;
> 			}
> 			else
> 			{
> 				cout <<setw(4 - out) <<' ';
> 			}
> 		}
> 		memset(Bowler, 0, sizeof(Bowler));
> 		memset(Score, 0, sizeof(Score));
> 		memset(Count, 0, sizeof(Count));
> 		memset(Kick, 0, sizeof(Kick));
> 	}
> 	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