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

是你循环的问题吧

Posted by sothink at 2004-10-17 21:57:33 on Problem 1519
In Reply To:颇为蹊跷,诸位请看(系统提示:Run-time error) Posted by:2003011475 at 2004-09-09 16:33:53
> #include<iostream.h>
> #include<string.h>
> #include<stdlib.h>
> 
> char num[200];
> 
> void main()
> {
> 	cin>>num;
> 	while(strcmp(num,"0")!=0)
> 	{
> 		int sum=0;
> FIND:
> 		for(int i=0;num[i]!='\0';i++)//这个地方有问题
                                           
> 			sum+=(int(num[i])-int('0'));
> 		if(sum<10)
> 			cout<<sum<<endl;
> 		if(sum>=10)
> 		{
> 			for(int j=0;j<200;j++)
> 				num[j]=0;
> 			itoa(sum,num,10);
> 			sum=0;
> 			goto FIND;
> 		}
> 		for(int j=0;j<200;j++)
> 			num[j]=0;
> 		cin>>num;
> 	}
> }
> 

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