POJ 1503
2015-06-09 14:07
281 查看
#include <iostream> #include <string> #define MAXN 100000 using namespace std; //string _s[MAXN]; int ans[MAXN]; int main() { //freopen("acm.acm","r",stdin); string s; int i; int index; memset(ans,0,sizeof(ans)); index = 0; while(cin>>s,s != "0") { for(i = s.length()-1; i >= 0; -- i) { ans[index ++] += s[i]-'0'; } index = 0; } int c; int tem; c = 0; for(i = 0; i < MAXN; ++ i) { ans[i] += c; c = ans[i]/10; ans[i] %= 10; } bool boo = false; for(i = MAXN-1; i >= 0; -- i) { if(ans[i] != 0 && !boo) { cout<<ans[i]; boo = true; } else if(boo) cout<<ans[i]; } cout<<endl; }
相关文章推荐
- C and C++ 的困惑
- 年轻程序员的悲伤
- 2014年10月25日ACT考试写作真题及范文
- 驱动编译脚本
- poi导入图片到word
- Plus One
- 再造 “手机QQ” 侧滑菜单(一)——实现侧滑效果
- Leetcode[169]-Majority Element
- 大约ActionContext.getContext()使用体验
- 程序员保值的4个秘密
- 基于外部数据的用户信用评估
- POJ 1496
- C学习脚印
- CentOS系统的VPS安全设置与优化
- rpmbulid学习redis打包
- 模拟客户查看cdn节点的访问情况
- ABAP 上传、下载请求文件
- kindEditor,html编辑器用法与体会,及如何获取文本域中的值 (转)
- Directx11基于GeometryShader的粒子系统
- 网络取证原理与实战