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

有没有人提供点BT数据啊,我都WA疯了

Posted by NKU_Happy at 2010-09-28 10:35:10 on Problem 1076 and last updated at 2010-09-28 10:45:12
想不到什么特殊情况了.....
#include <iostream>
using namespace std;
//1076
char name[13],ans[12][4];
int pins[22],score[12],sframe,len,sscore;
void input(){for(int i=1;;i++){scanf("%d",&pins[i]);if(pins[i]==-1){len=i;break;}}}
int tscore(int x,int y){if(x==-1||y==-1) return 0;else if(x==0) return 20-y;else return 10-y;}
int tscore(int x){if(x==-1) return 0;return 10-x;}
void tchar(int x,int y,int z,int k)
{
	ans[k][0] = 'X';
	if(y==-1){ans[k][1] = '\0';return;}	
	if(k==10)
	{
		if(y==0){ans[k][1]='X';if(z==-1){ans[k][2]='\0';return;}if(z==0)ans[k][2]='X';else if(z==10)ans[k][2]='-';else ans[k][2]=(char)(10-z+'0');}
		else if(y==10){ans[k][1]='-';if(z==-1){ans[k][2]='\0';return;}if(z==0)ans[k][2]='/';else if(z==10)ans[k][2]='-';else ans[k][2]=(char)(10-z+'0');}
		else{ans[k][1]=(char)(10-y+'0');if(z==-1){ans[k][2]='\0';return;}if(z==0)ans[k][2]='/';else if(z==y)ans[k][2]='-';else ans[k][2]=(char)(y-z+'0');}
		ans[k][3]= '\0';
	}
	else ans[k][1] = '\0';	
}
void tchar(int x,int z,int k)
{
	if(x==10) ans[k][0]='-';
	else ans[k][0] = (char)(10-x+'0');
	ans[k][1]='/';
	if(k!=10||z==-1)ans[k][2]='\0';
	else 
	{
		if(z==0) ans[k][2]='X';
		else if(z==10) ans[k][2]='-';
		else ans[k][2] = char(10-z+'0');
		ans[k][3]='\0';
	}
}
void tchar1(int x,int y,int k)
{
	if(x==10) ans[k][0]='-';
	else ans[k][0] = char(10-x+'0');
	if(y==-1){ans[k][1]='\0';return;}
	if(x==y) ans[k][1]='-';
	else ans[k][1] = char(x-y+'0');
	ans[k][2]='\0';
}
int cal(int s,int &k)//计算从第s次击打开始的第K帧的分数和结果
{
	if(pins[s]==0)//第一次击打完全
	{	
		score[k] = score[k-1]+tscore(pins[s+1],pins[s+2])+10;
		tchar(pins[s],pins[s+1],pins[s+2],k);
		if(pins[s+2]!=-1&&pins[s+1]!=-1) sscore++;
		k++;
		return s+1;
	}
	else if(pins[s+1]==0)//第二次击打完全
	{
		score[k] = score[k-1]+tscore(pins[s+2])+10;
		tchar(pins[s],pins[s+2],k);
		if(pins[s+2]!=-1&&pins[s+1]!=-1) sscore++;
		k++;
		return s+2;
	}
	else //两次都没有击打全
	{
		score[k] = score[k-1]+tscore(pins[s],pins[s+1]);
		tchar1(pins[s],pins[s+1],k);
		if(pins[s+2]!=-1&&pins[s+1]!=-1) sscore++;
		k++;
		return s+2;
	}
}
void solve()
{
	int s=1;sframe = sscore = 1;
	while(s<=len&&sframe<=10&&pins[s]!=-1)
		s=cal(s,sframe);		
	
}
void output()
{
	int i;
	/*for(i=1;i<=52;i++) printf("%d",i%10);//标尺
	printf("\n");*/

	printf("%-13s",name);//姓名
	for(i=1;i<sframe;i++)printf("%-4s",ans[i]);//记分牌
	printf("\n            ");
	for(i=1;i<sscore;i++)printf("%4d",score[i]);//分数
	printf("\n\n");	
}
int main(void)
{
	while (scanf("%s",name)!=EOF)
	{
		input();
		solve();
		output();
		memset(name,'\0',sizeof(name));
	}
	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