博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 2057 A + B Again
阅读量:4696 次
发布时间:2019-06-09

本文共 974 字,大约阅读时间需要 3 分钟。

Problem 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
我以前完全不知道还有%I64这个东西。
%I64X可以对数据读入输出进行操作。但问题在于直接用%I64X,是不能输出负数的,所以我们碰到负数要自己转成正数,
在前面加‘-’(如果直接输入A的话,那么输出为FFFFFFF6,为A的补码)。
#include
int main(){ __int64 a,b,c; while(scanf("%I64x%I64x",&a,&b)!=EOF) { c=a+b; if(c>=0) printf("%I64X\n",c); else printf("-%I64X\n",-c); } return 0;}

 

转载于:https://www.cnblogs.com/duan-to-success/p/3507154.html

你可能感兴趣的文章
为什么wait()和notify()属于Object类
查看>>
PHP 在5.1.* 和5.2.*之间 PDO数据库操作中的不同!
查看>>
导入properties时的坑
查看>>
配置NRPE的通讯
查看>>
shp系列(一)——利用C++进行shp文件的读(打开)与写(创建)开言
查看>>
匹配两个空格之间的字符。。。
查看>>
CSS 文字溢出 变成省略号 ...
查看>>
Spring事务
查看>>
java编程基础(三)流程控制语句
查看>>
让数据库跑的更快的7个MySQL优化建议
查看>>
jquery 取id模糊查询
查看>>
解决在vue中,自用mask模态框出来后,下层的元素依旧可以滑动的问题
查看>>
修改node节点名称
查看>>
PAT(B) 1014 福尔摩斯的约会(Java)
查看>>
PAT甲级题解-1123. Is It a Complete AVL Tree (30)-AVL树+满二叉树
查看>>
项目开发总结报告(GB8567——88)
查看>>
SSH加固
查看>>
端口扫描base
查看>>
iOS IM开发的一些开源、框架和教程等资料
查看>>
FansUnion:共同写博客计划终究还是“流产”了
查看>>