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 |
are you still dreaming of fitting the input into an int?In Reply To:run time error!!!who can help me!!! Posted by:00 at 2005-04-22 00:48:34 > #include<iostream.h> > #include<math.h> > int n,i,j,s; > int *m; > void main() > { > for(;;) > { > cin>>n; > if(n==0) > break; > for(;;) > { > for(i=0;;i++) > { > if(n/(long)pow(10,i)==0) > break; > } > m=new int[i]; > for(j=0;j<i;j++) > { > m[j]=n/(int)pow(10,i-j-1); > n-=m[j]*(int)pow(10,i-j-1); > } > s=0; > for(j=0;j<i;j++) > s+=m[j]; > if(s/10==0) > { > cout<<s<<endl; > break; > } > else > n=s; > delete [] m; > } > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator