02-4. BCD decryption (10)

Source: Internet
Author: User

BCD is a two-digit decimal number expressed in one byte. Each four bits represents one digit. Therefore, if the hexadecimal value of a BCD number is 0x12, it represents 12 in decimal format. However, James did not learn BCD, and converted all BCD numbers into decimal numbers. Therefore, 0x12 of BCD is output to 18 in decimal format!

Now, your program will read the incorrect decimal number and output the correct decimal number. Tip: You can convert 18 to 0x12 and then to 12.

Input Format:

The input gives a positive integer in the range of [0,153] in a row to ensure that the number of BCD is converted back to a valid number, that is, this integer is converted to a hexadecimal number without a A-F.

Output Format:

Output the corresponding decimal number.

Input example:

18

Output example:

12

Note: two methods: 1. the same number is stored in the computer, so you only need to specify the output format. directly convert to hexadecimal, and then remove the hexadecimal mark 0x. The output is BCD.

# Include "stdio. H" int main () {int A; scanf ("% d", & A); printf ("% x", a); Return 0 ;}

 

# Include "stdio. H "int main () {int A; scanf (" % d ", & A); printf (" % d ", A/16*10 + A % 16 ); 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.