# include & lt; Math. H>
# include & lt; String. H>
Int main ()
{
Int [1000] e={0}, n.
Char a, [1000].
Char b [1000];
Int I, j, d=0, m, x, y, sum1, sum2, w, s;
Int min;
int count=0;
scanf("%d",& n);
While (d
Sum2=0;
Count=0;
The scanf (" % d % d ", & amp; W, & amp; S);//formal, use
getchar();
Gets (a);
getchar();
Gets (b);
X=strlen (a);
Y=strlen (b);
for(i=0; i
If (a [I]=='H' | | a [I]=='S' | | a [I]=='D' | | a [I]=='C')
{
If (a [I + 1)=='a')
{
Sum1 +=11; count++;
}
Else if (a [I + 1)=='1')
Sum1 +=10;
The else
Sum1 +=a + 1] [I - '0'.
}
}
If (sum1 & gt; 21 & amp; & The count!=0)
Sum1=sum1 - count * 11 + count;
If (sum1 & gt; 21 & amp; & The count==0)
Sum1=0;
Count=0;
for(i=0; i
If (b [I]=='H' | | b [I]=='S' | | b [I]=='D' | | b [I]=='C')
{
If (b [I + 1)=='A')
{
Sum2 +=11; count++;
}
Else if (b [I + 1)=='1')
Sum2 +=10;
The else
Sum2 +=b + 1] [I - '0';
}
}
If (sum2 & gt; 21 & amp; & The count!=0)
Sum2=sum2 - count * 11 + count;
If (sum2 & gt; 21 & amp; & The count==0)
Sum2=0;
If (sum1 & gt; Sum2)
E [d]=1;//tag who wins
D++;
}
for(i=0; i
If (e [I]==0)
Printf (" Case % d: Bob \ n ", I + 1);
The else
Printf (" \ n "Case % d: Alice, I + 1);
}
return 0;
}
CodePudding user response:
Settled, to the scanf (" % d % d ", & amp; W, & amp; S); Switch toThe scanf (" % d % d ", & amp; W, & amp; S);
CodePudding user response:
Two getchar can be removedCodePudding user response:
The scanf (" % d % d ", & amp; W, & amp; S); And the scanf (" % d % d ", & amp; W, & amp; S); No difference, but in the former will be betterUse white space between the scanf input number, number of character segmentation, whitespace is a space, TAB or enter
This is the scanf automatically support, don't need you to specify
You can enter 1 2 enter
You can be 1 enter 2 enter
There is no difference between
Your problem is appeared on the two calls getchar, is redundant, but cause side effects, enter from the normal effective data also to carry away
Don't need, keyboard buffer enter, the scanf will automatically filter
Yourself after the scanf printf immediately once, will know whether the right obtained results
Online have a heap of said how to filter the keyboard buffer in return, but, but, but, that is, in the case of a single character input
You don't have a single character input requirements, there is no necessary to monkey around
CodePudding user response:
Each group of dataFirst the scanf (" % d % d ", & amp; W, & amp; S);
And then the line of four or more, the cycle have to do is to read the string
Char STR [20]
For (I=0; I
Although the H10 H3 is a line, but there is space, % s own back to distinguish between them
CodePudding user response:
Fun