Wanzm_Alymine @ 2023-02-18 22:39:10
帮忙看看
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
int a[15], c;
char b;
scanf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-%c",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&b);
int sum = 0;
for (int i = 1;i <= 9;i ++)
{
sum += a[i] * i;
}
int key = sum % 11;
if (b == 'X')
{
c = 10;
}
else
{
c = int(b - '0');
}
if (key == c)
{
cout << "Right";
}
else
{
cout << a[1] << "-" << a[2] << a[3] << a[4] << "-" << a[5] << a[6] << a[7] << a[8] << a[9] << "-" << key;
}
return 0;
}
dev样例无误
by guozhe6241 @ 2023-02-19 00:10:27
key为X的情况你没考虑
by Wanzm_Alymine @ 2023-02-19 20:27:04
@guozhe6241 我来看看昂
by Wanzm_Alymine @ 2023-02-19 20:30:00
@guozhe6241 貌似没有欸,key可以为10,上面有判断,如果b为x的话那么c就为10,可以与key对上
by guozhe6241 @ 2023-02-20 19:35:04
@Wanzm 但你最后输出的是key啊???