[What should I do if my book is missing] ISBN number

Source: Internet
Author: User

[Description]

Each officially published book corresponds to an ISBN number. The ISBN code consists of nine digits, one-digit identification code, and three separators, the format is as follows: "X-xxx-XXXXX-X", where the symbol "-" is a separator (minus sign on the keyboard), and the last digit is an identifier, for example, 0-670-82162-4 is a standard ISBN code. The first digit of the ISBN code represents the publishing language of the book. For example, 0 represents English, and three digits after the first separator "-" represent the publishing house, for example, 670 represents the Viking Publishing House; the fifth digit after the second separator represents the number of the book in the press; the last digit is the identification code.
The identifier calculation method is as follows:
Multiply the first digit by 1 and the second digit by 2 ...... Similarly, if mod 11 is used, the remainder is the identification code. If the remainder is 10, the identification code is an uppercase letter X. For example, Id 4 of ISBN numbers 0-670-82162-4 is obtained as follows: for the 9 Numbers 067082162, multiply them from left to right by 1, 2 ,..., 9, then sum, that is, 0x1 + 6x2 + ...... + 2 × 9 = 158, and then take Result 4 of 158 mod 11 as the identification code.
Your task is to writeProgramDetermine whether the ID in the ISBN number is correct. If it is correct, only "right" is output. If it is incorrect, the ISBN number you think is correct.

[Input format]

The input file ISBN. In has only one line. It is a character sequence that represents the ISBN number of a book (ensure that the input meets the ISBN number format requirements ).

[Output format]

Output file ISBN. if the input ISBN number has a correct identifier, the output is "right". Otherwise, the correct ISBN number (including the separator "-") is output according to the specified format.

[Input example]

Input Example 1 Input Example 2
0-670-82162-4 0-670-82162-0

[Output example]

Output Example 1 Output Example 2
Right 0-670-82162-4

[Analysis]

I did not explain it.

 

# Include <stdio. h> int A [10], B, TB; char C; int main () {scanf ("% d", & A [1]); scanf ("% C", & C); For (INT I = 2; I <5; ++ I) {scanf ("% C", & C ); A [I] = C-'0';} scanf ("% C", & C); For (INT I = 5; I <10; ++ I) {scanf ("% C", & C); A [I] = C-'0';} scanf ("% C", & C ); scanf ("% C", & C); If (C = 'X') TB = 10; else TB = C-'0'; For (INT I = 1; I <10; ++ I) B + = A [I] * I; B % = 11; If (B = Tb) printf ("right \ n "); else {printf ("% d-", a [1]); For (INT I = 2; I <5; ++ I) printf ("% d ", A [I]); printf ("-"); For (INT I = 5; I <10; ++ I) printf ("% d ", A [I]); printf ("-"); If (B = 10) printf ("x \ n"); else printf ("% d \ n ", b);} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.