题解 | #[NOIP2008]ISBN号码#

[NOIP2008]ISBN号码

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

import java.util.Scanner;
import java.lang.String;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] isbn=sc.nextLine().split("-");//分开
        int one=Integer.parseInt(isbn[0]);
        int two=Integer.parseInt(isbn[1]);
        int three=Integer.parseInt(isbn[2]);
        int count1=one*1;
        int count2=(two/100)*2+(two%100/10)*3+(two%10)*4;
        int count3=(three/10000)*5+(three%10000/1000)*6+(three%1000/100)*7+(three%100/10)*8+(three%10)*9;
        int count=(count1+count2+count3)%11;
        if(count==10)
        {
            if(isbn[3].equals("X"))
            {
                 System.out.println("Right");
            }else{
                System.out.println(one+"-"+two+"-"+three+"-X");
            }
        }else{
            if(isbn[3].equals(String.valueOf(count)))
            {
                System.out.println("Right");
            }else{
                System.out.println(one+"-"+two+"-"+three+"-"+count);
            }
        }
    }
}

全部评论

相关推荐

那一天的Java_Java起来:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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