wuming10086 @ 2024-09-20 17:14:19
#include<iostream>
using namespace std;
int main(){
string s;
cin>>s;
int num=0;
for(int i=0,j=1;i<=12&&j<=9;i++,j++){
if(s[i]=='-')continue;
num+=j*(s[i]-'0');
}
num=num%11;
char x='x';
if(num==10)x='X';
else x=num+'0';
if(s[12]==x)cout<<"Right";
else {s[12]=x;cout<<s;}
return 0;
}
by Hhy140516 @ 2024-09-20 17:24:50
你这是写错了啊,
by Yxy7952 @ 2024-09-20 17:42:22
@wuming10086
求关
#include<iostream>
using namespace std;
int main(){
string s;
cin>>s;
int num=0;
for(int i=0,j=1;i<=12&&j<=9;i++){
if(s[i]=='-')continue;
num+=j*(s[i]-'0');
j++;
}
num=num%11;
char x='x';
if(num==10)x='X';
else x=num+'0';
if(s[12]==x)cout<<"Right";
else {s[12]=x;cout<<s;}
return 0;
}
by yangfengzhao @ 2024-09-20 17:50:56
@wuming10086
这是我的,求关:
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
char ISBN[1000];
int mul=1,sum=0;
int main()
{
scanf("%s",ISBN+1);
for(int index=1;index<=11;index++)
{
if(ISBN[index]=='-')
{
continue;
}
else
{
sum+=mul*(ISBN[index]-48);
mul++;
}
}
sum%=11;
if(ISBN[13]==sum+48||ISBN[13]=='X'&&sum%11==10)
{
printf("Right");
}
else
{
for(int index=1;index<=12;index++)
{
printf("%c",ISBN[index]);
}
if(sum<10)printf("%d",sum);
if(sum==10)printf("X");
}
return 0;
}
by wuming10086 @ 2024-09-20 18:58:36
@Yxy7952 我懂了,那个j++条件位置写错了,关注有了