shelbyloveshiking @ 2024-11-11 21:06:55
为什么提示wa呢,我按照输入验证过,输出没有问题。而且提示“read r,expected 4”,很奇怪
#include <stdio.h>
int main ()
{
char isbn[14];
int num[10];
int count,sum = 0;
scanf ("%s",isbn);
for (int i=0;i<13;i++)
{
if (isbn[i] == '-')
{
count ++;
continue;
}
else if (isbn[i] == 'X')
num[i-count] = 10;
else
num[i-count] = isbn[i] - 48;
}
for (int i=0;i<9;i++)
sum += num[i]*(i+1);
if (num[9] == 10)
{
if (sum%11 == 10)
printf ("Right");
else
{
isbn[12] = sum%11 + 48;
printf("%s",isbn);
}
}
else
{
if (sum%11 == 10)
{
isbn[12] = 'X';
printf("%s",isbn);
}
else if (sum%11 == num[9])
printf ("Right");
else
{
isbn[12] = sum%11 + 48;
printf("%s",isbn);
}
}
return 0;
}
by _dbq_ @ 2024-11-11 21:11:14
@shelbyloveshiking 样例过了不代表代码就是对的
by _dbq_ @ 2024-11-11 21:12:28
@shelbyloveshiking 代码写错了
by _dbq_ @ 2024-11-11 21:14:39
@shelbyloveshiking 服务器读取到你输出 r 但是正确答案应该是读取到 4
by shelbyloveshiking @ 2024-11-11 21:47:55
@dbq 谢谢大佬!但是我下载了测试数据,dev c++上跑出来结果是对的,洛谷上面就通不过。而且我压根没写会输出r的代码。。。