anchorage @ 2022-06-30 23:40:03
#include <iostream>
using namespace std;
int main() {
char s[50];
cin.getline(s,50);
int sum=0,cnt=1,i;
for(i=0;i<11;i++)
{
if(s[i]>='0'&&s[i]<='9')
{
sum+=((int)(s[i]-'0'))*(cnt++);
}
}
if(sum%11==10)
{
if(s[12]=='X') cout<<"Right";
else
{
s[12]='X';
cout<<s;
}
}
else
{
if(sum%11==s[12]) cout<<"Right";
else
{
s[12]=sum%11+48;
cout<<s;
}
}
return 0;
}
by Blikewsr @ 2022-07-01 06:46:17
else
{
if(sum%11==s[12]) cout<<"Right";
else
{
s[12]=sum%11+48;
cout<<s;
}
}
sum
是数字, s
是字符, 他们的 ASCLL
码不同, 因改为 :
else
{
if(sum%11==(s[12]-'0')) cout<<"Right";
else
{
s[12]=sum%11+48;
cout<<s;
}
}
by Blikewsr @ 2022-07-01 06:46:42
@anchorage
by anchorage @ 2022-07-01 18:57:23
@百位必备 非常感谢