比赛 20150714B 评测结果 AWAWAWAWWA
题目名称 拱猪计分 最终得分 50
用户昵称 Bennettz 运行时间 0.004 s
代码语言 C++ 内存使用 0.29 MiB
提交时间 2015-07-14 11:28:44
显示代码纯文本
#include <stdio.h>
int score(char strlist[])
{
    int i,isS=0,isC=0,isD=0,countH=0,Hnum[14],score=0;
	int Hlist[14]={0,-50,-2,-3,-4,-5,-6,-7,-8,-9,-10,-20,-30,-40};
    for(i=0;strlist[i]!='\0';i++)
    {
        if(strlist[i]=='S') isS=1;
        else if(strlist[i]=='C') isC=1;
        else if(strlist[i]=='D') isD=1;
        else if(strlist[i]=='H')
        {
			countH++;
			if(strlist[i+2]==' '||strlist[i+2]=='\0') Hnum[countH]=strlist[i+1]-'0';
			else Hnum[countH]=10+strlist[i+2]-'0';
        }
    }
	if(countH==13)
	{
		score=200;
		if(isS&&isD) score=500;
		else if(isS) score-=100; 
		else if(isD) score+=100;
	}
	else if(0 <=countH && countH <13)
	{
		for(i=1;i <=countH;i++) score+=Hlist[Hnum[i]];
		if(isS) score-=100;
		if(isD) score+=100;
	}
	if(isC)
	{
        if(isS==0 && isD==0 && countH==0) score=50; 
        else score*=2; 
    }
	return score;
}
int	main()
{
	freopen("heart.in","r",stdin);
	freopen("heart.out","w",stdout);
	char a[4][100];
    int i,j,result[10][4],count=0;
    while(1)
    {
            for(i=0;i <=3;i++)  gets(a[i]);
            if(a[0][0]=='0'&&a[1][0]=='0'&&a[2][0]=='0'&&a[3][0]=='0')  break;
            for(i=0;i <=3;i++)  result[count][i]=score(a[i]);
            count++;
    }
    for(i=0;i <=count-1;i++)
	{
            for(j=0;j <=3;j++)
            {
                if(j <3)  (result[i][j] <=0)?printf("%d ",result[i][j]):printf("+%d ",result[i][j]);
                else    (result[i][j] <=0)?printf("%d\n",result[i][j]):printf("+%d\n",result[i][j]);
            }
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}