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. c3p0xml配置详解

    <?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <default-con ...

  2. 返回某个界面——nav

     NSInteger index=[[self.navigationController viewControllers]indexOfObject:self];  [self.navigationC ...

  3. OpenCV——Mat,IplImage,CvMat类型转换

    Mat,cvMat和IplImage这三种类型都可以代表和显示图像,三者区别如下 Mat类型侧重于计算,数学性较高,openCV对Mat类型的计算也进行了优化. 而CvMat和IplImage类型更侧 ...

  4. CMarkUp读写XML(转)

    Fast start to XML in C++ Enough bull. You want to create XML or read and find things in XML. All you ...

  5. C++中const

    [const] 0.普通const对象定义在栈空间中 { ; ; cout << &a << ' ' << &b; } Result: 0x22ab ...

  6. git rm

    git rm可以执行删除的条件(前提是要被删除的文件还没有从workspace tree中移除) git rm可以执行删除的条件:被删除文件在index当中的blob内容必须与HEAD commit指 ...

  7. PHP基础示例:用PHP+Mysql编写简易新闻管理系统

    实现目标:使用php和mysql操作函数实现一个新闻信息的发布.浏览.修改和删除操作 实现步骤: 一.创建数据库和表 1.创建数据库和表:newsdb 2.创建表格:news 字段:新闻id,标题,关 ...

  8. c++连接mysql数据库(使用mysql api方式,环境VS2013+MYSQL5.6)

    转载请注明出处,原文地址http://www.cnblogs.com/zenki-kong/p/4382657.html 刚开始写博客,博主还只是个大三汪,学艺不精,如有错误还请前辈指出(>^ω ...

  9. 指令中 controller && controllerAs

    1, controller 他会暴露一个API,利用这个API可以在多个指令之间通过依赖注入进行通信. controller($scope, $element, $attrs, $tranclude) ...

  10. Python学习笔记五,函数及其参数

    在Python中如何自定义函数:其格式为 def 函数名(函数参数): 内容