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);
 
  1. #include<stdio.h>
  2. int main()
  3. {
  4. __int64 a,b,c;
  5. char s[];
  6. while(scanf("%I64X%I64X",&a,&b)!=EOF)
  7. {
  8. c=a+b;
  9. if(c<)
  10. printf("-%I64X\n",-c);
  11. else
  12. printf("%I64X\n",c);
  13. }
  14. return ;
  15. }

随机推荐

  1. PHP学习笔记三十二【Exception】

    <?php // $fp=fopen("a.txt","r"); // echo "ok"; if(!file_exists(&quo ...

  2. UIProgressView 圆角

    里面外面都变成圆角 不用图片 直接改变layer 重点是里面外面都是圆角哦 for (UIImageView * imageview in self.progress.subviews) { imag ...

  3. DataGridView常用功能

    最近做Winform开发,DataGridView是必不可少的控件.整理了一下用到的基本功能的设置 1.情景1:当GridView的列没有自动填充,会出现一片空白的地方,特别不美观. 设置 自动填充G ...

  4. Comparator TreeSet

    package study; import java.util.Comparator;import java.util.TreeSet; public class TreeSetTest { publ ...

  5. Java IO5:管道流、对象流

    前言 前面的文章主要讲了文件字符输入流FileWriter.文件字符输出流FileReader.文件字节输出流FileOutputStream.文件字节输入流FileInputStream,这些都是常 ...

  6. uva 1595 Symmetry“结构体”

    给出平面上N(N<=1000)个点.问是否可以找到一条竖线,使得所有点左右对称,如图所示: 则左边的图形有对称轴,右边没有.   Sample Input  3 5 -2 5 0 0 6 5 4 ...

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

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

  8. java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet

  9. 典型的DIV CSS三行二列居中高度自适应布局

    如何使整个页面内容居中,如何使高度适应内容自动伸缩.这是学习CSS布局最常见的问题.下面就给出一个实际的例子,并详细解释.(本文的经验和是蓝色理想论坛xpoint.guoshuang共同讨论得出的.) ...

  10. js加载优化

    阻塞特性:       JS 有个很无语的阻塞特性,就是当浏览器在执行JS 代码时,不能同时做其他任何事情,无论其代码是内嵌的还是外部的. 脚本位置:       浏览器在碰到一个引入外部JS 文件的 ...