-->
当前位置:首页 > 题库 > 正文内容

PROGRAMMING:Check ISBN-10 code

Luz4年前 (2021-05-10)题库424
Books are encoded by international standard book number (ISBN-10), which is a 10 digit code. The first nine digits ($$0-9 $) are used for language, publisher and book information respectively. The 10th bit is the check bit, which can be a number between $$0-9 $$or the letter X (used to represent the number $$10 $);
ISBN-10 code can be verified by the following methods:
1. First of all, sum the bits of ISBN-10 code according to the following formula
$$1\times x_ 1 + 2\times x_ 2 + 3\times x_ 3 + 4\times x_ 4 \cdots + 9\times x_ 9+10\times x_{ 10}$$
2. Take the remainder of the sum result to $$11 $. If the remainder is $$0 $, then the ISBN-10 code is a valid code. Otherwise, it is not a valid ISBN-10 code.
Now input a batch of ISBN-10 book code, please verify whether the code is a valid international standard book number.
###Input format:
Input the first line to give a positive integer n (≤ 10) is the number of ISBN-10 book number input. Then n lines, each line gives a 10 digit ISBN-10 book number.
###Output format:
According to the order of input, one ISBN-10 code with problem is output for each line. Here * * does not check whether the first nine digits are reasonable, only check whether the first nine digits are all numbers and the last check code is calculated accurately * *. If all numbers are normal, output 'all passed'.
###Input sample 01:
```in
one
0072880082
```
###Output sample 01:
```out
All passed
```
###Input sample 02:
```in
two
0072880082
084930149X
```
###Output sample 02:
```out
084930149X
```
###Input sample 03:
```in
three
013168728X
X615880991
026201A530
```
###Output sample 03:
```out
X615880991
026201A530
```






answer:If there is no answer, please comment

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。