lte_z @ 2024-11-14 12:13:37
代码如下:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, ans = 0;
char ISBN[14];
for(int i = 0;i < 13;i += 1)
{
cin >> ISBN[i];
if(ISBN[i] != '-' && i < 12)
{
if(ISBN[i] == 'X')
ans += 10 * (n + 1);
else
ans += (ISBN[i] - '0') * (n + 1);
n += 1;
}
}
if(ans % 11 == ISBN[12] - '0' || (ans % 11 == 10 && ISBN[12] == 'X'))
cout << "Right" << endl;
else
{
for(int i = 0;i < 12;i += 1)
cout << ISBN[i];
cout << ans % 11 << endl;
}
return 0;
}
求教!!!
by 3288xiao @ 2024-11-14 12:30:25
n没初始化
by complete_binary_tree @ 2024-11-14 12:33:44
1:n没初始化
2:输出时没判 10(要变成 X)
@lte_z