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

Re:结果都对着,不明白为什么会runtime error?请高手看一下

Posted by LiZhiXu at 2006-07-22 22:06:01
In Reply To:结果都对着,不明白为什么会runtime error?请高手看一下 Posted by:zhtsuc at 2006-07-22 21:46:22
> #include<iostream.h>
> int a[10001];
> int sum(int n)
> {
> 	int res=0;
> 	while(n!=0)
> 	{
> 		res+=n%10;
> 		n=n/10;
> 	}
> 	return res;
> }
> void main()
> {
> 	int i;
> 	for(i=1;i<10001;i++)
> 		a[i+sum(i)]=-1;//这个地方如果i == 10000就越界了
> 	for(i=1;i<10001;i++)
> 		if(a[i]!=-1)
> 			cout<<i<<endl;
> }

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