| ||||||||||
| 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 | |||||||||
Re:开数组的,数组要开到1000.。。才过,再也不信题目给的条件了In Reply To:开数组的,数组要开到1000.。。才过,再也不信题目给的条件了 Posted by:sw9416 at 2010-05-04 17:38:28 #include<iostream>
#include<string>
using namespace std;
int main()
{
char a[2000];
int b[2000]={0},i,j,k;
while(cin>>a&&strcmp(a,"0")!=0){
int tmp=0,le,ra[2000]={0};
le=strlen(a);
for(i=0;i<le;i++)
ra[i]=a[i]-'0';
for(j=0;j<le;j++){
b[j]=b[j]+ra[le-j-1]+tmp;
if(b[j]>=10){
b[j]=b[j]-10;
tmp=1;
}
else tmp=0;
}
b[le]=b[le]+tmp;
if(b[le]>=10){b[le]-=10;tmp=1;}
else tmp=0;
b[le+1]+=tmp;
}
for(k=1999;k>=0;k--){
if(b[k]!=0) break;
}
k++;
while(k--) cout<<b[k];
cout<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator