A + B Problem II &&http://acm.hdu.edu.cn/showproblem.php?pid=1002
来源:互联网 发布:jquery ajax json参数 编辑:程序博客网 时间:2024/05/17 23:47
水题继续。。大数相加。。
#include<iostream>#include<string>#include<algorithm>#include<string.h>using namespace std;int a[1001];int main(){ int n; cin>>n; for(int v=1;v<=n;++v) { string s,s1; cin>>s>>s1; memset(a,0,sizeof(a)); int len1=s.size(); int len2=s1.size(); int len=max(len1,len2); for(int i=len1-1;i>=0;--i) a[i]+=s[len1-1-i]-'0'; for(int i=len2-1;i>=0;--i) a[i]+=s1[len2-1-i]-'0'; int carry=0; for(int i=0;i<=len;++i) { a[i]+=carry; carry=a[i]/10; a[i]%=10; } int p; cout<<"Case "<<v<<":"<<endl; cout<<s<<" + "<<s1<<" = " ; for(int i=len;i>=0;--i) if(a[i]!=0) {p=i;break;} for(int i=p;i>=0;--i) cout<<a[i]; cout<<endl; if(v!=n) cout<<endl; }return 0;}
- A + B Problem II &&http://acm.hdu.edu.cn/showproblem.php?pid=1002
- A/B&&http://acm.hdu.edu.cn/showproblem.php?pid=1576
- http://acm.hdu.edu.cn/showproblem.php?pid=1005
- http://acm.hdu.edu.cn/showproblem.php?pid=1333
- http://acm.hdu.edu.cn/showproblem.php?pid=2710
- http://acm.hdu.edu.cn/showproblem.php?pid=2866
- http://acm.hdu.edu.cn/showproblem.php?pid=1041
- http://acm.hdu.edu.cn/showproblem.php?pid=1719
- http://acm.hdu.edu.cn/showproblem.php?pid=2136
- http://acm.hdu.edu.cn/showproblem.php?pid=1166
- http://acm.hdu.edu.cn/showproblem.php?pid=3519
- http://acm.hdu.edu.cn/showproblem.php?pid=2446
- http://acm.hdu.edu.cn/showproblem.php?pid=1709
- http://acm.hdu.edu.cn/showproblem.php?pid=1874
- http://acm.hdu.edu.cn/showproblem.php?pid=1863
- http://acm.hdu.edu.cn/showproblem.php?pid=1879
- http://acm.hdu.edu.cn/showproblem.php?pid=1875
- http://acm.hdu.edu.cn/showproblem.php?pid=1102
- 2012 年感悟
- 内存碎片 Memory Fragmentation
- android学习笔记29:simpleAdapter
- C#加密方法汇总
- 去掉tppabs冗余代码
- A + B Problem II &&http://acm.hdu.edu.cn/showproblem.php?pid=1002
- AGG学习之九----自带gsv_text对象raster方式绘制字符
- IMSI的相关转换
- 如何产生获取WAS的heapdump
- Clojue:开发学习Clojure中有用的资源
- C#的关键字 [STAThread]
- sed
- Eclipse快捷键大全(转载)
- 缺点