题目链接在这里
http://chjsgl.openjudge.cn/pr...
赋上我的代码:
#include<stdio.h>
#include<string.h>
char a[12][3];
char b[12][3];
int n, m;
int main()
{
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%s", a[i]);
for (int i = 0; i < m; i++)
scanf("%s", b[i]);
int cnta1 = 0;
int cnta2 = 0;
int cntjqk1 = 0;
int cntjqk2 = 0;
int sum1 = 0;
int sum2 = 0;
int flag1 = 0;
int flag2 = 0;
for (int i = 0; i < n; i++)
{
if (strcmp(a[i], "A") == 0)
{
sum1 += 1;
cnta1++;
}
else if (strcmp(a[i], "10") == 0)
{
sum1 += 10;
cntjqk1++;
}
else if (strcmp(a[i], "J") == 0)
{
sum1 += 10;
cntjqk1++;
}
else if (strcmp(a[i], "Q") == 0)
{
sum1 += 10;
cntjqk1++;
}
else if (strcmp(a[i], "K") == 0)
{
sum1 += 10;
cntjqk1++;
}
else
sum1 += a[i][0] - '0';
}
if (n == 2 && cnta1 == 1 && cntjqk1 == 1)
flag1 = 1;
while (cnta1 != 0 && sum1 <= 21)
{
sum1 += 10;
cnta1--;
}
for (int i = 0; i < m; i++)
{
if (strcmp(b[i], "A") == 0)
{
sum2 += 1;
cnta2++;
}
else if (strcmp(b[i], "10") == 0)
{
sum2 += 10;
cntjqk2++;
}
else if (strcmp(b[i], "J") == 0)
{
sum2 += 10;
cntjqk2++;
}
else if (strcmp(b[i], "Q") == 0)
{
sum2 += 10;
cntjqk2++;
}
else if (strcmp(b[i], "K") == 0)
{
sum2 += 10;
cntjqk2++;
}
else
sum2 += b[i][0] - '0';
}
if (m == 2 && cnta2 == 1 && cntjqk2 == 1)
flag2 = 1;
while (cnta2 != 0 && sum2 <= 21)
{
sum2 += 10;
cnta2--;
}
if (sum2 > 21)
puts("win");
else if (sum1 > 21)
puts("lose");
else if (flag1 == 1 && flag2 == 0)
puts("win");
else if (flag1 == 0 && flag2 == 1)
puts("lose");
else if (flag1 == 1 && flag2 == 1)
puts("draw");
else if (sum1 > sum2)
puts("win");
else if (sum1 < sum2)
puts("lose");
else if (sum1 == sum2)
puts("draw");
return 0;
}
题目给的那个测试用例也过了,但是提交总是不对,不知道问题出现在哪里,还请高手帮帮忙!!谢谢啦!!O(∩_∩)O~