A+B Coming 解题报告
来源:互联网 发布:mac好用软件 编辑:程序博客网 时间:2024/05/22 14:23
http://acm.sdibt.edu.cn/JudgeOnline/problem.php?id=1563
A+B Coming
Time Limit: 1 Sec Memory Limit: 125 MBSubmissions: 32 Solved: 15
[Submit][Status][Discuss]
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
代码:
- #include <iostream>
- using namespace std;
- int a,b;
- int main(){
- while(cin>>hex>>a>>b)
- cout<<dec<<a+b<<endl;
- return 0;
- }
- /**************************************************************
- Problem: 1563
- User: mmoaay
- Language: C++
- Result: Accepted
- Time:0 ms
- Memory:1352 kb
- ****************************************************************/
刚开始的时候自己写的16进制转10进制,结果无耻地错了,然后更无耻的是:原来如此简单……
有必要总结一下c++输入输出数的进制问题:
dec-十进制(默认)
oct-八进制
hex-十六进制
在cin和cout中指明相应的数据形式。
例:
- int i,j,k,l;
- cout<<"Input i(oct) j(hex) k(hex) l(dec):"<<endl;
- cin>>oct>>i; //输入为八进制数
- cin>>hex>>j; //输入为十六进制数
- cin>>k; //输入仍为十六进制数
- cin>>dec>>l; //输入为十进制数
- cout<<"hex:"<<"i="<<hex<<i<<endl;
- cout<<"dec:"<<"j="<<dec<<j<<'/t'<<"k="<<k<<endl;
- cout<<"oct:"<<"l="<<oct<<l;
- cout<<dec<<endl; //恢复十进制输出状态
- A+B Coming 解题报告
- 【ACM解题报告】A+B Coming
- 杭电OJ题1720 A+B Coming 解题报告
- A - A+B(解题报告)
- E - A + B解题报告
- A+B Coming 1720
- A+B Coming
- HDU1720 A+B Coming
- 1720 A+B Coming
- HDOJ1720 A+B Coming
- HDU1720 A+B Coming
- A+B Coming
- fjnu 1000 A+B Problem 解题报告
- HDOJ 1412 {A} + {B}解题报告
- FOJ1650-A^B mod C解题报告
- 解题报告(A,B,C)
- 解题报告之 a+b(1)
- codeforces # 285 解题报告A.B.C
- THE FIRST!
- ASP.NET web.config配置大全
- cin.getline,cin.get,cin.ignore,cin.clear用法(转)
- IP地址、子网掩码、网关的关系?
- c++
- A+B Coming 解题报告
- Top 20 Programming Lessons I've Learned in 20 Years
- 风雨20年:我所积累的20条编程经验
- 人生态度
- 自己选择的路跪着也要走完
- vs2008 MFC中如何添加和删除消息函数?
- 亲爱的 我想你了
- Array对象
- Greedy Reluctant Possessive 正则表达式