| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
怎么回事啊?#include<iostream>
#include<string>
using namespace std;
int main(){
string s[2];
int *p[2];
int n,l1,l2,i=0;
cin>>n;
while(i<n){
int j=1;
cin>>s[0];
cin>>s[1];
l1=s[0].length();
l2=s[1].length();
p[0]=new int[l1+1];
p[1]=new int[l2+1];
while(j<=l1){
p[0][j]=s[0][l1-j]%48;
j++;
}
j=1;
while(j<=l2){
p[1][j]=s[1][l2-j]%48;
j++;
}
int sum=0;
int IsShort,IsLong,flag;
if(l1>=l2){
IsLong=l1;
IsShort=l2;
flag=0;
}
else{
IsLong=l2;
IsShort=l1;
flag=1;
}
p[flag][0]=0;
l1=IsLong;
while(IsShort>=1){
sum=p[flag][IsLong]+p[1-flag][IsShort];
p[flag][IsLong]=sum%10;
IsLong--;
IsShort--;
p[flag][IsLong]=p[flag][IsLong]+sum/10;
}
int a=0;
if(p[flag][0]==0)
a=1;
bool zero=false;
while(l1>=a){
if(p[flag][l1])
zero=true;
if(zero)
cout<<p[flag][l1];
l1--;
}
cout<<endl;
i++;
}
return 0;
}
有什么特殊数据吗?帮帮忙吧
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator