Love丶FFC's Blog
每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字、1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如0代表英语;第一个分隔符“-”之后的三位数字代表出版社,例如670代表维京出版社;第二个分隔之后的五位数字代表该书在出版社的编号;最后一位为识别码。
识别码的计算方法如下:
首位数字乘以1加上次位数字乘以2……以此类推,用所得的结果mod 11,所得的余数即为识别码,如果余数为10,则识别码为大写字母X。例如ISBN号码0-670-82162-4中的识别码4是这样得到的:对067082162这9个数字,从左至右,分别乘以1,2,…,9,再求和,即0×1+6×2+……+2×9=158,然后取158 mod 11的结果4作为识别码。
编写程序判断输入的ISBN号码中识别码是否正确,如果正确,则仅输出“Right”;如果错误,则输出是正确的ISBN号码。
输入只有一行,是一个字符序列,表示一本书的ISBN号码(保证输入符合ISBN号码的格式要求)。
输出一行,假如输入的ISBN号码的识别码正确,那么输出“Right”,否则,按照规定的格式,输出正确的ISBN号码(包括分隔符“-”)。
0-670-82162-4
Right
0-670-82162-0
0-670-82162-4
1.求出正确识别码
2.判断实际识别码与正确识别码
package CCF_CSP; import java.util.Scanner; public class _20131202_100point { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String ISBN = scanner.next(); //输入ISBN号 String rightISBN = ISBN.substring(0, 12); //存放正确的ISBN号的前11位 int recognizecode = (Integer.parseInt(ISBN.charAt(0)+"")*1+Integer.parseInt(ISBN.charAt(2)+"")*2 +Integer.parseInt(ISBN.charAt(3)+"")*3+Integer.parseInt(ISBN.charAt(4)+"")*4+Integer.parseInt(ISBN.charAt(6)+"")*5+ Integer.parseInt(ISBN.charAt(7)+"")*6+Integer.parseInt(ISBN.charAt(8)+"")*7+Integer.parseInt(ISBN.charAt(9)+"")*8+ Integer.parseInt(ISBN.charAt(10)+"")*9) % 11; //首先求出正确识别码 if(recognizecode == 10) //如果识别码为10,则需要用X替代 { if((ISBN.charAt(12)+"").equals("X")==true) //识别码正确 { System.out.println("Right"); } else //识别码错误 { rightISBN += "X"; //追加正确识别码 System.out.println(rightISBN); } } else { if((ISBN.charAt(12)+"").equals(recognizecode+"")==true) //识别码正确 { System.out.println("Right"); } else //识别码错误 { rightISBN += recognizecode; //追加正确识别码 System.out.println(rightISBN); } } } }
FoorryNox
droperidol increases and arformoterol decreases sedation buy cialis generic online Advantages vs
Preliaf
A number of pharmaceuticals that are not prescribed as hormonally active drugs have been shown to cause rodent mammary tumors Rudel et al viagra boys warsaw
oeSIvKeBl
In addition, a case of sclerosing glomerulonephritis has been reported in a postmenopausal woman with breast cancer after ASZ adjunct therapy initiation 49, pointing to the importance of monitoring renal outcomes in future clinical studies for aromatase inhibitors occasion levitra Asymptomatic increases in aspartate AST SGOT and or alanine ALT SGPT aminotransferase levels greater than 3 times the upper limit of normal of the laboratory reference range have been reported in up to 8