Java实现 洛谷 P1055 ISBN号码
2024-09-07 12:11:00
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String args[]) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String ISBN = reader.readLine();
String[] temp = ISBN.split("-");
String str = "";
int check = 0;
int x = 0;
String front = ISBN.substring(0, ISBN.length() - 1);
for (int i = 0; i < temp.length; i++){
str += temp[i];
}
for (int i = 0; i < str.length()-1; i++){
x = Integer.parseInt(String.valueOf(str.charAt(i)));
check += (i+1)*x;
}
if (str.charAt(str.length()-1)=='X'){
if (check % 11 == 10) {
System.out.println("Right");
} else {
System.out.println(front + check % 11);
}
} else {
if (check%11 == Integer.parseInt(String.valueOf(str.charAt(str.length()-1)))){
System.out.println("Right");
} else {
if (check % 11 == 10) {
System.out.println(front + "X");
} else {
System.out.println(front + check % 11);
}
}
}
}
}
最新文章
- 理解ThreadLocal(之一)
- 史上最全最强SpringMVC详细示例实战教程
- 好用的php类库和方法
- GridView与CheckBox完美结合
- eclipse出现每次修改代码报heap over错误,然后必须重启tomcat问题,修改过程
- ActiveMQ(5.10.0) - Building a custom security plug-in
- module_init宏解析 linux驱动的入口函数module_init的加载和释放
- Javascript的AMD规范
- 在linux下实现UBOOT的TFTP下载功能
- bzoj3668
- oracle11g ora-12514监听程序当前无法识别
- IIS7.0 Appcmd 命令详解
- string函数详解(配案例)
- 线程相关的sleep()、yield()、wait()、join()方法介绍
- python入门(九):目录操作
- ASP.NET Core中使用Autofac
- linux中weblogic相关命令操作
- 4、JUC--CountDownLatch闭锁
- Zuul Timeouts
- 构造字典:DictionaryBase类和SortedList类
热门文章
- 马上要去bupt参加培训了。。
- xsser和XSStrike
- Nginx服务器的安装和卸载
- 实战!我用 Wireshark 让你“看得见“ TCP
- 【雕爷学编程】Arduino动手做(60)---WS2812直条8位模块
- git init 后关联github仓库是发生错误:
- django中ckeditor富文本编辑器使用
- 06.drf(django)的权限
- block和delegate的选择
- PAT-1018 Public Bike Management(dijkstra + dfs)