zoukankan      html  css  js  c++  java
  • Java实现 洛谷 P1055 ISBN号码

    在这里插入图片描述

    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);
                    }
                }
            }
        }
    }
    
  • 相关阅读:
    beta版本冲刺七
    beta版本冲刺六
    beta版本冲刺五
    beta版本冲刺四
    beta版本冲刺三
    Beta版本冲刺(二)
    项目评测
    beta版本冲刺(一)
    福大软工 · 最终作业
    福大软工 · 第十二次作业
  • 原文地址:https://www.cnblogs.com/a1439775520/p/12947075.html
Copyright © 2011-2022 走看看