QAQ___awa @ 2022-04-28 19:28:36
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
char s[13];
int main()
{
int ans=0,bj=1;
gets(s);
for(int i=0;i<13;i++)
{
if(s[i]>='1'&&s[i]<='9')
{
ans+=(s[i]-'0')*bj;
bj++;
}
}
ans%=11;
if(ans==s[12]-48)
{
cout<<"Right";
}
else if(ans==10&&s[12]=='X')cout<<"Right";
else
{
for(int i=0;i<13;i++)
{
cout<<s[i];
}
cout<<ans;
}
return 0;
}
by QAQ___awa @ 2022-04-28 19:29:44
改一下
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
char s[13];
int main()
{
int ans=0,bj=1;
gets(s);
for(int i=0;i<13;i++)
{
if(s[i]>='1'&&s[i]<='9')
{
ans+=(s[i]-'0')*bj;
bj++;
}
}
ans%=11;
if(ans==s[12]-48)
{
cout<<"Right";
}
else if(ans==10&&s[12]=='X')cout<<"Right";
else
{
for(int i=0;i<13;i++)
{
cout<<s[i];
}
cout<<ans;
}
return 0;
}
by QAQ___awa @ 2022-04-28 19:30:39
现在输出 0-670-82162-7
by _Remake_ @ 2022-04-28 19:35:16
@QAQ___awa 那说明您的ans算错了
by _Remake_ @ 2022-04-28 19:36:50
if(s[i]>='1'&&s[i]<='9')
改为
if(s[i]>='0'&&s[i]<='9')
还有
for(int i=0;i<13;i++)
改为
for(int i=0;i<12;i++)
by w23c3c3 @ 2022-04-28 19:37:28
最后那个不应该算上吧。