参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String in = scanner.nextLine(); String []s = in.split("-"); String all = s[0] + s[1] + s[2]; int sum = 0; int i = 0; for(char c: all.toCharArray()) sum += (c - '0') * ++i; String mod = (sum % 11 == 10) ? "X" : "" + sum % 11; if(s[3].equals(mod)) System.out.print("Right"); else System.out.print(s[0] + "-" + s[1] + "-" + s[2] + "-" + mod); } }
0.0分
4 人评分
C语言程序设计教程(第三版)课后习题5.7 (C++代码)浏览:879 |
数组输出 (C语言代码)错误???浏览:602 |
【排队买票】 (C语言代码)浏览:944 |
简单的a+b (C语言代码)浏览:674 |
WU-小九九 (C++代码)浏览:1713 |
C语言程序设计教程(第三版)课后习题6.3 (C++代码)浏览:1067 |
C语言程序设计教程(第三版)课后习题6.5 (C++代码)浏览:487 |
矩形面积交 (C++代码)浏览:1204 |
数字游戏 (C++代码)浏览:1240 |
IP判断 (C语言代码)浏览:592 |