2-4. BCD decryption (10), 2-4 BCD decryption 10
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
1 # include <stdio. h> 2 3 int main () 4 {5 int x; 6 scanf ("% d", & x); 7 int n; 8 n = x/16*10 + (x-x/16*16); 9 printf ("% d", n); 10 11 return 0; 12}
The 6789 (BCD) Code of (8421) 10 is
(6789) 10 8421 (BCD) Code
0110 0111 1000 1001
OK?
How to unlock Hisense BCD-237 inverter refrigerator buttons
1. Press the "Frozen" and "Frozen" keys for 5 seconds and then release them;
2. Unlock the lock for more than 2 seconds.
If you have a manual, take a look.
Try it.