Maysoul @ 2022-03-18 16:16:20
一年前的远古代码,求助
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a[10];
int b=0,c=0,d=0;
scanf("%d-%d%d%d-%d%d%d%d%d-%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
for (int i=1;i<=9;i++)
{
b+=a[c]*i;
c++;
}
d=b%11;
if (d=10)
{
if(a[9]=='X')
{
cout<<"Right";
}
else
{
printf("%d-%d%d%d-%d%d%d%d%d-X",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]);
}
}
else
{
if(a[9]==d)
{
cout<<"Right";
}
else
{
printf("%d-%d%d%d-%d%d%d%d%d-%d",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],d);
}
}
return 0;
}
by Anamnesis @ 2022-03-18 16:17:48
- if (d=10)
+ if (d==10)
by Jasper08 @ 2022-03-18 16:17:54
@Maysoul
//P1055 ISBN 号码
#include <iostream>
using namespace std;
int main()
{
int cnt = 0, ans = 0;
char num[15];
for (int i = 0; i < 12; ++i)
{
cin >> num[i];
if ('0' <= num[i] && num[i] <= '9') //输入 9个数字
{
cnt += 1;
ans += cnt * (num[i] - '0');
}
}
char tisbn; //转换最后一位验证码
cin >> tisbn;
int isbn;
if ('0' <= tisbn && tisbn <= '9')
isbn = tisbn - '0';
else //此时验证码为 X,即 10
isbn = 10;
if (ans % 11 == isbn)
cout << "Right";
else
{
for (int i = 0; i < 12; ++i)
cout << num[i];
if (ans % 11 == 10)
cout << "X";
else
cout << ans % 11;
}
}
by Maysoul @ 2022-03-18 16:20:42
@Linking⭐️ 这……竟然会有这种rz错误,我自裁