A+B Coming
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9659 Accepted Submission(s): 6309
Problem Description
Many classmates said to me that A+B is must needs.
If you can’t AC this problem, you would invite me for night meal. ^_^
If you can’t AC this problem, you would invite me for night meal. ^_^
Input
Input may contain multiple test cases. Each case contains A and B in one line.
A, B are hexadecimal number.
Input terminates by EOF.
A, B are hexadecimal number.
Input terminates by EOF.
Output
Output A+B in decimal number in one line.
Sample Input
1 9 A B a b
Sample Output
10 21 21
///////1
#include<stdio.h>
int
main()
{
int
a,b;
while
(~scanf(
"%x
%x"
,&a,&b))
{
printf(
"%d\n"
,a+b);
}
return
0
;
}
///////2
#include <iostream>
using namespace std;
int main()
{
int a,b;
while( cin>>hex>>a>>b)
{
cout << a+b<<endl;
}
return 0;
}
////拓展
cin>>oct>>i; //输入为八进制数 4 cin>>hex>>j; //输入为十六进制数 5 cin>>k; //输入仍为十六进制数 6 cin>>dec>>l; //输入为十进制数 7 cout<<”hex:”<<”i=”<<hex<<i<<endl; 8 cout<<”dec:”<<”j=”<<dec<<j<<′\t′<<”k=”<<k<<endl; 9 cout<<”oct:”<<”l=”<<oct<<l; 10 cout<<dec<<endl; //恢复十进制输出状态//本题就是一个十六进制数的加法,上面附带了一些可能用到的输入。