AcWing 3193. ISBN号码
原题链接
简单
作者:
xiaozuo99
,
2021-02-17 16:55:43
,
所有人可见
,
阅读 291
时间复杂度
参考文献
JAVA 代码
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.next();
char[] arr = str.toCharArray();
int res = 0 ;
char t = '0';
int count = 1;
for(int i = 0;i<12;i++){
if(arr[i] == '-') continue;
res = res + (arr[i]-'0')*(count);
count++;
}
res = res%11;
if(res == 10){
t = 'X';
}else{
t = String.valueOf(res).charAt(0);
}
if(t == arr[12]){
System.out.println("Right");
}else{
System.out.println(str.substring(0,12)+t);
}
}
}