杭电 OJ 1720 A+B Coming

来源:互联网 发布:建立党建工作网络平台 编辑:程序博客网 时间:2024/05/20 09:09

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. ^_^
 

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.
 

Output
Output A+B in decimal number in one line.
 

Sample Input
1 9A Ba b
 

Sample Output
102121

///////1

#include<stdio.h>
intmain()
{
    inta,b;
    while(~scanf("%x %x",&a,&b))
    {
        printf("%d\n",a+b);
    }   
     
    return0;
}
///////2

#include <iostream>

using namespacestd;

int main()

{

    int a,b;

    while(cin>>hex>>a>>b)

    {

        cout << a+b<<endl;

    }

    return0;

}

////拓展
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; //恢复十进制输出状态
//本题就是一个十六进制数的加法,上面附带了一些可能用到的输入。






原创粉丝点击