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. Entity Framework Code First主外键关系映射约定

    本篇随笔目录: 1.外键列名默认约定 2.一对多关系 3.一对一关系 4.多对多关系 5.一对多自反关系 6.多对多自反关系 在关系数据库中,不同表之间往往不是全部都单独存在,而是相互存在关联的.两个 ...

  2. 对Lucene PhraseQuery的slop的理解[转载]

    所谓PhraseQuery,就是通过短语来检索,比如我想查“big car”这个短语,那么如果待匹配的document的指定项里包含了"big car"这个短语,这个documen ...

  3. appStore应用发布流程

    原文转自: http://blog.sina.com.cn/s/blog_68661bd801019uzd.html       首先确定帐号是否能发布, https://developer.appl ...

  4. Ext JS中Button的一般使用

    Ext JS中Button按钮的显示,以及按钮的部分事件 一.属性 renderTo:将当前对象所生成的HTML对象存放在指定的对象中 text:得到按钮名称 minWidth:按钮最小宽度 hidd ...

  5. Mvc音乐商店demo的ajax异步删除功能总结

    刚刚从学校出来参加工作,没啥工作经验,所以各位大神们不要嘲笑哈! 来公司后要进行培训,给我们的作业中有一个使用 dapper+mvc+ajax+SQL Server 2008,来实现一个音乐商店的de ...

  6. web_profile(网站分析)配置

    web_profiler: # DEPRECATED, it is not useful anymore and can be removed # safely from your configura ...

  7. python 核心编程第六章课后题自己做的答案

    6–6. 字符串.创建一个 string.strip()的替代函数:接受一个字符串,去掉它前面和后面的 空格(如果使用 string.*strip()函数那本练习就没有意义了) 'Take a str ...

  8. javascript跨域获取json数据

    项目在开发过程中,用到了天气预报的功能,所以需要调用天气预报的api,一开始以为直接用ajax调用url就可以获取天气数据,结果涉及到了跨域的问题,这里做一个记录. 说到跨域,就得知道同源策略. 同源 ...

  9. python----特性003

    python特性003:计算特性 #!/usr/local/bin/python3.5 class MyNumber(object): def __init__(self,number): self. ...

  10. 【HDU 4547 CD操作】LCA问题 Tarjan算法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4547 题意:模拟DOS下的cd命令,给出n个节点的目录树以及m次查询,每个查询包含一个当前目录cur和 ...