我是靠谱客的博主 懦弱唇彩,最近开发中收集的这篇文章主要介绍HDU 2057 A + B Again,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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
 

Author
linle
 

Source
校庆杯Warm Up

思路:16进制输入输出,  注意“The length of A and B is less than 15. ”  ,也就是说,数据范围不在int里面,要用long long。
代码:
#include<stdio.h>
int main()
{
    int a,b,res;
    while(~scanf("%llX %llX",&a,&b))
    {
        if(a+b>=0)
            printf("%llXn",a+b);//如果是小写的x的话,也会wa
        else
            printf("-%llXn",-a-b);
    }
    return 0;
}

最后

以上就是懦弱唇彩为你收集整理的HDU 2057 A + B Again的全部内容,希望文章能够帮你解决HDU 2057 A + B Again所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部