题解 | #[NOIP2008]ISBN号码#

[NOIP2008]ISBN号码

https://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int res = 0,start = 1;;
        for (int i = 0; i < str.length()-1; i++) {
            if(str.charAt(i)=='-') continue;
            res += Integer.parseInt(Character.toString(str.charAt(i)))*start;
            start++;
        }
        res %= 11;
        String result  = new StringBuilder(str).deleteCharAt(str.length()-1).toString();
        if(res == 10){
            result = result + "X";
        }else {
            result = result + res ;
        }
        if(result.equals(str)){
            System.out.println("Right");
        }else {
            System.out.println(result);
        }
    }
}

#笔试##九江银行#
全部评论

相关推荐

求个付费实习岗位:这种就是吃满时代红利又没啥技术水平,只能靠压力学生彰显优越感的老登,别太在意了
点赞 评论 收藏
分享
程序员花海_:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务