记录编号 259372 评测结果 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
题目名称 加法问题 最终得分 0
用户昵称 Gravatar背对疾风吧 是否通过 未通过
代码语言 C++ 运行时间 0.025 s
提交时间 2016-05-08 23:56:13 内存使用 13.66 MiB
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. using namespace std;
  5. int main()
  6. {
  7. freopen("aplusb.in","r",stdin);
  8. freopen("aplusb.out","w",stdout);
  9. string s1,s2;
  10. int a[120],b[120],he;
  11. int i;
  12. memset(a,0,sizeof(a));
  13. memset(b,0,sizeof(b));
  14. cin>>s1>>s2;
  15. a[0]=s1.length();
  16. for(i=1;i<=a[0];i++)
  17. {a[i]=s1[a[0]-i]-'0'; }
  18. b[0]=s2.length(); // 实验谁最帅?背对疾风吧!
  19. for(i=1;i<=b[0];i++)
  20. {b[i]=s2[b[0]-i]-'0'; }
  21. he=(a[0]>b[0]?a[0]:b[0]);
  22. for(i=1;i<=he;i++)
  23. {
  24. a[i]+=b[i];
  25. a[i+1]+=a[i]/10;
  26. a[i]%=10;
  27. }
  28. he++;
  29. while((a[he]==0)&&(he>1)) he--;
  30. for(i=he;i>=1;i--)
  31. cout<<a[i];
  32.  
  33. }