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 windbells at 2004-11-21 16:21:05 on Problem 2081
In Reply To:各位给我看看程序吧;俺郁闷!!!!!!!!! Posted by:tide713 at 2004-11-21 16:07:37
> //我在vc上不能运行,但是把数组改小点就能行了。可是改小了又不满足题目要求。。求救。
> #include<stdio.h>
> #include<iostream.h>
> void main()
> {   long a,i,j;
>     long  m[50000];
>     while(1)
> 	{   
> 		cin>>a;
> 		if(a==-1)
>           break;
> 		for(i=0;i<50000;i++)
> 			m[i]=0;
> 		for(i=1;i<=a;i++)
> 		{ 
>                      m[i]=m[i-1]-i;
> 		   
> 		   if(m[i]<=0)
> 		   {m[i]=m[i-1]+i;continue;}
> 		   for(j=0;j<i;j++)
> 		   {   
> 			   if(m[j]==m[i])
> 			   {   m[i]=m[i-1]+i;
> 			       break;
> 			   }
> 		   }
> 		}
> 		cout<<m[a]<<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