Sky_Aurora @ 2023-09-14 20:32:22
各位神犇,这段代码我的思路应该没有问题,但是跑评测却是0分,神犇帮忙debug下,谢谢!
#include<iostream>
using namespace std;
int main()
{
string ISBN;
cin >> ISBN;
int sum = 0,n = 1;
for (int i = 0;i < 13;i++)
{
if (ISBN[i] == '-')
{
continue;
}
sum += (ISBN[i] - '0') * n;
n++;
}
sum = sum % 11;
char sum_char;
if (sum < 10)
{
sum_char = sum + '0';
}
else
{
sum_char = 'X';
}
if (sum_char == ISBN[12])
{
cout << "Right" << endl;
}
else
{
ISBN[12] = sum_char;
cout << ISBN << endl;
}
return 0;
}
by xuchuhan @ 2023-09-14 20:48:14
@Jacky_luogu 最后一位是识别码,不记入
by Sky_Aurora @ 2023-09-14 22:10:13
@xuchuhan 哦哦哦,知道了,谢谢神犇~\ 我改下看看
by Sky_Aurora @ 2023-09-14 22:18:24
@xuchuhan AC了,谢谢神犇!