#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(){
char a[14], mod[12] = "0123456789X"; //先将mod11后的十一个字符存入数组
scanf("%s", a); //洛谷用gets读取不让过
int i, j = 1, t = 0;
for(i = 0; i < 12; i++) {
if(a[i] == '-') continue; //字符串为分隔符‘-’时跳过此次循环进入下一次循环
t += (a[i]-'0')*j++; //t储存 第j个 数字 * j 的和
}
if(mod[t%11] == a[12]) printf("Right");
else {
a[12] = mod[t%11]; //若识别码错误,则赋正确的识别码,然后输出
puts(a);
}
return 0;
}
P1055 ISBN号码
最新推荐文章于 2024-02-01 13:44:14 发布