linjinkun @ 2023-09-30 10:31:12
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a,b,c,e;
int a1,b1,c1,d1;
scanf("%d-%d-%d-%d",&a1,&b1,&c1,&d1);
a = to_string(a1);
b = to_string(b1);
c = to_string(c1);
e = a+b+c;
int sum = 0;
for(int i = 0;i<e.size();i++)
{
sum+=(e[i]-'0')*(i+1);
}
if(sum%11 == 10)
{
if(d1 == 88)
{
cout << "Right";
}
else
{
cout << a1 << '-' << b1 << '-' << c1 << '-' << 'X';
}
}
else
{
if(d1 == sum%11)
{
cout << "Right";
}
else
{
cout << a1 << '-' << b1 << '-' << c1 << '-' << sum%11;
}
}
return 0;
}
by 123WRz @ 2023-09-30 15:40:11
建议不用string,可以用char类型的数组
by linjinkun @ 2023-10-01 09:17:04
那有什么问题?