Description

There must be many A + B problems in our HDOJ , now a new one is coming.         Give you two 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 two 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 in one line.        
                

Sample Input

+A -A +1A 12 1A -9 -1A -12 1A -AA
                

Sample Output

0 2C 11 -2C -90
 
 
十六进制两数相加并输出十六进制
定义 __int64  即可    
C语言输入输出十六进制 用 “%X”   输入__int64的十六进制为"%I64X“
所以直接相加减 
但是 电脑储存的数为补码   结果若为正数则无影响  但若为负数  则必须将结果变为正数输出  printf("-%I64X\n",-c);
 
#include<stdio.h>
int main()
{
__int64 a,b,c;
char s[];
while(scanf("%I64X%I64X",&a,&b)!=EOF)
{
c=a+b;
if(c<)
printf("-%I64X\n",-c);
else
printf("%I64X\n",c);
}
return ;
}

随机推荐

  1. 并行开发学习随笔1——plinq并行

    这两天在看园友的文章 <8天玩转并行开发——第三天 plinq的使用> 对里面的第一个实例亲手实践了一下,发现了一点有意思的事情. 测试环境:.net 4.5 64位(如果是32位的,测试 ...

  2. CDZSC_2015寒假新人(1)——基础 g

    Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...

  3. jdk配置环境变量

    介绍在linux下配置jdk环境变量的几种常用方法. 首先在linux下安装jdk,如果出现提示权限不够(且root下也提示权限不够),可用#ls -l filename命令查看一下,如果显示类似如: ...

  4. 【solr基础教程之一】Solr相关知识点串讲

           Solr是Apache Lucene的一个子项目.Lucene为全文搜索功能提供了完备的API,但它只作为一个API库存在,而不能直接用于搜索.因此,Solr基于Lucene构建了一个完 ...

  5. Excel Aspose.Cells 设置单元格格式 为数字

    Workbook workbook = new Workbook(); //工作簿 Worksheet sheet = workbook.Worksheets[]; //工作表 sheet.Cells ...

  6. js特殊字符转义

    点的转义:. ==> \\u002E 美元符号的转义:$ ==> \\u0024 乘方符号的转义:^ ==> \\u005E 左大括号的转义:{ ==> \\u007B 左方括 ...

  7. 整合spring2 + struts1.2 + hibernate3.2 .

    1 可恶的myeclipse     为了开发方便,我选择了myeclipse,因为它集成了很多框架,而不致于自己去倒入很多lib.但就是因为这一点,成了我这次组合的致命伤.SSH因为其是开源框架,自 ...

  8. python:利用urllib查找计算机二级准考证号

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaYAAAEACAIAAAB3VkWnAAAgAElEQVR4nOydZ3gUR9bv+WhExhHnDH

  9. [转]浅谈C/C++内存泄露及其检测工具

    转自:http://www.cnblogs.com/taoxu0903/archive/2007/10/27/939261.html 对于一个c/c++程序员来说,内存泄漏是一个常见的也是令人头疼的问 ...

  10. opencv中cvCreateImage大图片时出错

    最近在做遥感图像的图像处理工作,使用了 OpenCV2.4.8来处理.遥感图像不同于一般图像的一个大的特点是图片容量超大,轻轻松松就能超过10000x10000个像素点,在OpenCV中使用cvCre ...