Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

are you still dreaming of fitting the input into an int?

Posted by frkstyc at 2005-04-22 00:49:48 on Problem 1519
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator