JynP @ 2023-10-04 17:08:43
#include<stdio.h>
int main()
{
char isbn[13];
int sum=0,k=0;
int temp;
scanf("%s",isbn);
for (int i =0 ; i<12;++i)
{
if (isbn[i] != '-')
{
k++;
temp = isbn[i] - '0';
sum += k*temp;
}
}
sum %= 11;
if (sum == 10 && isbn[12] == 'X')
printf("Right");
else if (sum == isbn[12] - '0')
printf("Right");
else
{
if (sum == 10)
sum = 'X';
isbn[12] = sum + '0' ;
printf("%s",isbn);
}
return 0;
}
by Aoxiangcar @ 2023-10-05 10:36:58
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a,b,c;
char d,q,w,r;
cin>>a>>q>>b>>w>>c>>r>>d;
int emo=c;
int e[9]={a,b/100,b/10%10,b%10,c/10000,c/1000%10,c/100%10,c/10%10,c%10};
int sum=0;
for(int i=1;i<=9;i++)
{
e[i-1]*=i;
sum+=e[i-1];
}
sum%=11;
if(sum==10)
{
if(d=='X')
printf("Right");
else
cout<<a<<"-"<<b<<"-"<<emo<<"-"<<"X";
}
else
{
if(sum==d-48)
printf("Right");
else
printf("%d-%d-%d-%d",a,b,emo,sum);
}
return 0;
}
```试试这样