soder123 @ 2024-01-20 15:09:48
#include<stdio.h>
int main()
{
int i,s=0,j=1;
char a[14],mod[12]="0123456789X";
scanf("%s",a);
for(i=0;i<=12;i++)
{
if(a[i]=='-')
{
s=s;
}
else
{
s+=(a[i]-'0')*j;
j++;
}
}
if(mod[s%11]!=a[12])
{
a[12]=mod[s%11];
printf("%s",a);
}
else
{
printf("Right");
}
return 0;
}
by Dream_Creator @ 2024-01-20 15:16:02
@soder123 把 i<=12
改成 i<12
#include<stdio.h>
int main()
{
int i,s=0,j=1;
char a[14],mod[12]="0123456789X";
scanf("%s",a);
for(i=0;i<12;i++)
{
if(a[i]=='-')
{
s=s;
}
else
{
s+=(a[i]-'0')*j;
j++;
}
}
if(mod[s%11]!=a[12])
{
a[12]=mod[s%11];
printf("%s",a);
}
else
{
printf("Right");
}
return 0;
}
by soder123 @ 2024-01-20 21:52:59
@Dream_Creator 懂了懂了,谢谢