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. 内存管理pbuf.h头文件源码解析——LwIP学习

    声明:个人所写所有博客均为自己在学习中的记录与感想,或为在学习中总结他人学习成果,但因本人才疏学浅,如果大家在阅读过程中发现错误,欢迎大家指正. LwIP的内核(core文件夹)文件中pbuf.c是包 ...

  2. C++ Primer Plus 6th 读书笔记 - 第6章 分支语句和逻辑运算符

    1. cin读取错误时对换行符的处理 #include <iostream> using namespace std; int main() { double d; char c; cin ...

  3. css pre如果同时运用了css的border-radius、 overflow两个属性且标签中内容太多时,外部div滚动条在firefox下滚动时很卡

    pre如果同时运用了css的border-radius. overflow两个属性且标签中内容太多时,外部div滚动条在firefox下滚动时很卡. 解决方法:去掉css中border-radius. ...

  4. [Head First Python]2. python of comment

    1- 多行注释 ''' ''' 或 """ """ '''this is the standard way to include a mul ...

  5. php 实现同一个账号同时只能一个人登录

    php 实现同一个账号同时只能一个人登录 张映 发表于 2015-01-22 分类目录: php 标签:mysql, nginx, openfire, php, redis 以前考虑过这个问题,今天实 ...

  6. JAVA JNI学习

    JAVA JNI   JNI是Java Native Interface的缩写,中文为JAVA本地调用.从Java1.1开始,Java Native Interface(JNI)标准成为java平台的 ...

  7. C# partial修饰符_分部类_分部方法

    今天翻了翻书,发现自己还是遗留下不少基础性的东西,老实说,不管一些基础的东西用到不用到都很应该了解,因为基础毕竟学习量不是很大. 一.分部类 什么是部分类呢?简单来说就是将一个类型或方法拆分到两个或多 ...

  8. setAdapter(adapter)空指针nullPointer 解决办法

    setAdapter(adapter)空指针nullPointer 解决办法 (2014-06-13 10:01:23) 转载▼ 标签: 旅游 分类: Android开发 如果setAdapter报空 ...

  9. mybatis写demo时遇到的问题

    写demo的时候,用mybatis的配置文件链接数据库,始终链接不上,太急人了.仔细查阅,发现在mysql中新增的表没有事务支持.还有就是mysql搜索引擎支持的不对.我换了一下 innodb的引擎, ...

  10. GNU C - 关于8086的内存访问机制以及内存对齐(memory alignment)

    一.为什么需要内存对齐? 无论做什么事情,我都习惯性的问自己:为什么我要去做这件事情? 是啊,这可能也是个大家都会去想的问题, 因为我们都不能稀里糊涂的或者.那为什么需要内存对齐呢?这要从cpu的内存 ...