Description
There must be many A + B problems in our hdoj, now A new one is coming. Give you and hexadecimal integers, your task is to calculate the sum of them,and print it in hexadecimal too. Easy? AC it!
Input
The input contains several test cases, please process to the end of the file. Each case consists of the hexadecimal integers a and B in a line seperated by a blank. The length of A and B is less than 15.
Output
For each test case,print the sum of A and B in hexadecimal on one line.
Sample Input
+a-a +1a 1a-9 -1a-12 1A-AA
Sample Output
0 2C 11-2c-90 Hex two add and output hex definition __int64 c Input Output hex with "%x" input __int64 hexadecimal "%i64x" so directly add minus but the number of computers stored in the complement result if positive It has no effect, but if it is negative, the result must be changed to a positive output printf ("-%i64x\n",-c);
#include <stdio.h>intMain () {__int64 a,b,c; Chars[ -]; while(SCANF ("%i64x%i64x", &a,&b)! =EOF) {C=a+b; if(c<0) printf ("-%i64x\n",-c); Elseprintf ("%i64x\n", c); } return 0;}
B-a + B Again