记录编号 31286 评测结果 AAAAAA
题目名称 打保龄球 最终得分 100
用户昵称 GravatarTruth.Cirno 是否通过 通过
代码语言 C++ 运行时间 0.002 s
提交时间 2011-11-02 09:31:28 内存使用 0.26 MiB
显示代码纯文本
#include <cstdio>
using namespace std;

int main(void)
{
	freopen("bowling.in","r",stdin);
	freopen("bowling.out","w",stdout);
	int i,n=0,right[12]={-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2},got1[12]={0},got2[12]={0},sco[10]={0},sum[10]={0};
	char str[5];
	while (n<=11&&scanf("%s%*c",&str)==1)
	{
		if (str[0]=='/')
		{
			right[n]=2;
			got1[n]=10;
			got2[n]=0;
		}
		else if (str[1]=='/'/*&&str[0]>='0'&&str[0]<='9'*/)
		{
			right[n]=1;
			got1[n]=str[0]-'0';
			got2[n]=10-got1[n];
		}
		else if (str[1]>='0'&&str[1]<='9')
		{
			right[n]=0;
			got1[n]=str[0]-'0';
			got2[n]=str[1]-'0';
		}
		else //if (str[1]>'9'||str[1]<'0')
		{
			right[n]=-1;
			got1[n]=str[0]-'0';
		}
		n++;
	}
	for (i=0;;i++)
	{
		if (right[i]==-2||right[i]==-1)
		{
			break;
		}
		else if (right[i]==0)
		{
			sco[i]=got1[i]+got2[i];
		}
		else if (right[i]==1)
		{
			if (right[i+1]!=-2)
				sco[i]=10+got1[i+1];
			else
				break;
		}
		else //if (right[i]==2)
		{
			sco[i]=10;
			if (right[i+1]==-2||right[i+1]==-1)
				break;
			else if (right[i+1]==0||right[i+1]==1)
				sco[i]+=got1[i+1]+got2[i+1];
			else if (right[i+1]==2)
			{
				if (right[i+2]==-2)
					break;
				else
					sco[i]+=10+got1[i+2];
			}
		}
		if (i!=0)
			sum[i]=sum[i-1]+sco[i];
		else
			sum[i]=sco[i];
		if (i==10)
			break;
	}
	n=i;
	for (i=0;i<n-1;i++)
		printf("%d ",sco[i]);
	printf("%d\n",sco[i]);
	for (i=0;i<n-1;i++)
		printf("%d ",sum[i]);
	printf("%d\n",sum[i]);
	fclose(stdin);
	fclose(stdout);
	return(0);
}