liu_jia_qi @ 2024-11-09 12:30:07
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
string s;
char a[15],t1;
int ans;
int b[15];
int main()
{
scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&t1);
for(int i=1;i<=9;i++)
ans += (a[i] - '0') * i;
ans %= 11;
int t2 = t1 - '0';
if(ans == t2){
cout<<"Right"<<endl;
}
else{
t2 = ans;//更新
if(t2 != 10)
printf("%c-%c%c%c-%c%c%c%c%c-%d",a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],t2);
else
printf("%c-%c%c%c-%c%c%c%c%c-X",a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]);
}
return 0;
}
by liu_jia_qi @ 2024-11-09 12:31:58
ans是计算总和 t1是识别码,t2是将其转换成数字
by AzusidNya @ 2024-11-09 12:36:03
输入的串中最后一位是 X 的情况没考虑
by liu_jia_qi @ 2024-11-09 18:50:34
@AzusidNya 我去谢谢您