cleey
望着那一丝海线,若隐若现。落日下的海霞,数不尽的美,看不完的醉
hdu 2057
A + B Again

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6546 Accepted Submission(s): 2850

Problem DescriptionThere 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 !
InputThe 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.
OutputFor each test case,print the sum of A and B in hexadecimal in one line.

Sample Input+A -A+1A 121A -9-1A -12 1A -AA
Sample Output02C11-2C-90


#include
using namespace std;
int main()
{
__int64 a,b,c;
while(scanf("%I64x%I64x",&a,&b)!=EOF)
{
c=a+b;
if(c<0){c=-c;printf("-");}
printf("%I64X\n",c);
}
return 0;
}

//c++输入输出16进制。

#include
#include
using namespace std;
intmain()
{
long longa,b,c;
while(cin>>hex>>a>>b)
{
c=a+b;
if(c<0)
{
c=-c;
cout<<'-'< }
else
cout< }
return0;
}
<< 上一篇 流量的了解 php字符加法 下一篇 >>
文章标签
随意 | Created At 2014 By William Clinton | 蜀ICP备14002619号-4 |