zoj 2001 Adding Reversed Numbers
2011-12-23 12:43
330 查看
#include "iostream" #include "string" #include "sstream" #include "stdio.h" #include "algorithm" using namespace std; int main() { int TestCase; cin >> TestCase; while (TestCase--) { string num1, num2, ans; int length; stringstream temp1, temp2, temp; int temp3, temp4, sum; cin >> num1 >> num2; reverse(num1.begin(), num1.end());//反转函数的使用 reverse(num2.begin(), num2.end()); temp1 << num1; temp1 >> temp3; temp2 << num2; temp2 >> temp4; sum = temp3 + temp4; temp << sum; temp >> ans; reverse(ans.begin(), ans.end()); length = ans.size(); if (length == 1) cout << ans << endl; else { int count = 0; while (ans[count] == '0') count++;//前导0的统计 for (int i = count; i < length; i++) printf("%c", ans[i]); cout << endl; } } }
相关文章推荐
- zoj 2001 Adding Reversed Numbers
- POJ 1504,ZOJ 2001,UVA 713, Adding Reversed Numbers,错误,已找到错误
- zoj 2001 Adding Reversed Numbers
- POJ 1504,ZOJ 2001,UVA 713, Adding Reversed Numbers,错误,已找到错误
- Adding Reversed Numbers(zoj 2001)
- zoj 2001 Adding Reversed Numbers
- ZOJ 2001 Adding Reversed Numbers
- ZOJ 2001 Adding Reversed Numbers
- ZOJ2001 POJ1504 Adding Reversed Numbers
- ZOJ 2001 Adding Reversed Numbers
- zoj 2001 Adding Reversed Numbers
- zoj2001 Adding Reversed Numbers
- zoj_2001 Adding Reversed Numbers
- zoj 2001 Adding Reversed Numbers
- ZOJ Problem Set - 2001 Adding Reversed Numbers
- zoj 2001 Adding Reversed Numbers(大水水一个~)
- UVA713 UVALive5539 POJ1504 ZOJ2001 Adding Reversed Numbers
- 大数问题 ZOJ Problem Set - 2001 Adding Reversed Numbers
- zoj 2001.Adding Reversed Numbers
- 2001_Adding Reversed Numbers(字符串类型数求和)