hdu 2057 A+B

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2057

For each test case,print the sum of A and B in hexadecimal in one line.

Sample Input
+A -A
+1A 12
1A -9
-1A -12
1A -AA
 
Sample Output
0
2C
11
-2C
-90

 

 1 #include <cstdio>  
 2 #include <iostream>  
 3 #include<algorithm>
 4 #include<math.h> 
 5 #include <string.h>  
 6 #include<queue>
 7 using namespace std;
 8 
 9 int main()
10 {
11     __int64 a,b;
12     while(scanf("%I64X %I64X",&a,&b)!=EOF)
13     {
14         a+=b;
15         if(a<0)
16         {
17             a=-a;
18             printf("-%I64X\n",a);
19         }
20         else
21             printf("%I64X\n",a);//由于%I64X,不能输出
22                                 //负数,所以负数的输出要做处理,注意要用 X 
23     }
24     return 0;
25  } 

 

posted @ 2015-11-24 18:22  pter  阅读(118)  评论(0编辑  收藏  举报