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 6_6 at 2008-08-05 17:02:04 on Problem 1666
#include <iostream>
using namespace std;
int main()
{
	int i,j=0,n,k=0,m=1,x,p[100000],sum=0;
	while(cin>>n&&n)
	{
		for(i=0;i<n;i++)
			cin>>p[i];	
		for(j=0;;j++)
		{
			for(i=0;i<n;i++)
			{
				if(p[i]%2!=0)
					p[i]=p[i]+1;			
			}
			x=p[0];
			for(i=0;i<n-1;i++)
				p[i]=p[i]/2+p[i+1]/2;
			p[n-1]=(p[n-1]/2)+(x/2);
			while(m)
			{
				if(p[k]==p[k+1])
					m=1,k++;
				else m=0;
				if(k==n-1)
				break;
			}
			m=1;
			if(k==n-1)
				break;
			k=0;
		}
		cout<<j<<" "<<p[0]<<endl;
	}
	return 0;
}


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