Problem : 1002 ( A + B Problem II )
来源:互联网 发布:辣条属于淘宝哪个类目 编辑:程序博客网 时间:2024/06/05 16:31
经验总结:一定要注意输出的格式,字符的空格,空行,一定要观察清楚。如本题的最后一个输出结果后面没有空行。最后代码实现的时候需要判断一下,代码如下
cout<<endl;if(m+1!=n)cout<<endl;
Problem : 1002 ( A + B Problem II ) Judge Status : Accepted
RunId : 10370349 Language : C++ Author : mnmlist
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
RunId : 10370349 Language : C++ Author : mnmlist
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include<iostream>#include<string.h>using namespace std;#define max 1001void main(){ char str1[max]={0},str2[max]={0}; int a[max],b[max],c[max]; int n; cin>>n; int k,temp,strmax; for(int m=0;m<n;m++) { k=0; cin>>str1>>str2; int num1=strlen(str1),num2=strlen(str2); for(int i=0;i<max;i++) { a[i]=0; b[i]=0; } if(num1>num2) strmax=num1; else strmax=num2; for(int j=0;j<num1;j++) { a[num1-j-1]=str1[j]-'0'; } for(int j=0;j<num2;j++) { b[num2-j-1]=str2[j]-'0'; } for(int j=0;j<strmax;j++) { temp=a[j]+b[j]+k; c[j]=temp%10; k=temp/10; } cout<<"Case "<<m+1<<":"<<endl; cout<<str1<<" + "<<str2<<" = "; if(k==1)cout<<1; for(int i=strmax-1;i>=0;i--) cout<<c[i]; cout<<endl; if(m+1!=n) cout<<endl; }}
0 0
- Problem-1002 : A + B Problem II
- 【HDOJ】 <Problem - 1002> : A + B Problem II
- Problem : 1002 ( A + B Problem II )
- 1002 A + B Problem II
- 1002 A + B Problem II
- 1002 A + B Problem II
- 1002 ( A + B Problem II )
- 1002 A + B Problem II
- 1002:A + B Problem II
- 1002 A + B Problem II
- 1002 A + B Problem II
- A + B Problem II (1002)
- 1002 A + B Problem II
- 1002 A + B Problem II
- [1002]: A + B Problem II
- 1002 A + B Problem II
- 1002 A + B Problem II
- 1002:A + B Problem II
- 【Cocos2d-x】cocos2d-x + socket
- C语言学习笔记之奇怪的地址问题
- hdu2095
- 判断滑动方向UITableView
- Sublime分屏配置
- Problem : 1002 ( A + B Problem II )
- 在eclipse中增加myeclipse的插件
- UISearchBar 自定义,加背景,取消按钮背景
- 基数排序
- 自己动手写操作系统 第六章 号外:中断处理流程详细分析
- 网络端口的自动翻转(Auto MDI/MDIX)
- HDU 4497 GCD and LCM(拆素数+组合)
- POJ 1273 最水最水的网络最大流
- SQL Server内存遭遇操作系统进程压榨案例