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 ;}