TLE_ZBR @ 2023-05-01 08:50:43
#include <iostream>
#include <cstring>
using namespace std;
char s[100005];
int sum=0;
bool flag=0;
int main()
{
cin>>s;
int j=1;
for (int i=0;i<strlen(s)-1;i++)
{
if(s[i]=='-') continue;
int x=s[i]-'0';
if(i==(strlen(s)-1)&&(s[i]-'0')==(sum%11))
{
cout<<"Right"<<endl;
flag=1;
break;
}
sum+=x*j++;
// cout<<sum<<" "<<sum%11<<endl;
}
if(flag==0)
{
for (int i=0;i<(strlen(s)-1); i++)
{
cout<<s[i];
}
if(sum%11==10)
{
cout<<"X"<<endl;
}
else
{
cout<<sum%11<<endl;
}
}
return 0;
}
by yqh9600 @ 2023-06-24 20:29:38
#include <iostream>
#include <cstring>//头文件不解释
using namespace std;
int main()
{
char s[14],c;
cin>>s;
int h=0,k=0;
for(int i=0;i<11;i++)
{
if(s[i]!='-')
{
k++;
h+=k*(s[i]-'0');//-0是为了将字符串变成普通数字
}
}
h%=11;
if(h==10) c='X';
else c=h+'0';
if(c==s[12]) cout<<"Right"<<endl;
else
{
s[12]=c;
cout<<s;
}
return 0;
}
by TLE_ZBR @ 2023-08-14 16:02:52
@yqh9600 感谢