AcWing 433. Java-10行写法
原题链接
简单
作者:
zlnnjit
,
2021-02-11 17:03:10
,
所有人可见
,
阅读 372
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine(), s = str.replaceAll("-", "");
int sum = 0;
for (int i = 0; i < s.length() - 1; i++) sum += Integer.parseInt(String.valueOf(s.charAt(i))) * (i + 1);
String last = "10".equals(String.valueOf(sum % 11)) ? "X" : String.valueOf(sum % 11);
if (last.equals(str.substring(12))) System.out.println("Right");
else System.out.println(str.substring(0, 12) + last);
}
}