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 29778945 at 2010-07-12 09:08:12 on Problem 1032
#include<iostream>
#define MAX 100
using namespace std;

int main()
{
	int n;
	cin>>n;
	int i,sum=0;
	int temp;
	int s[MAX];
	
	for(i=2;i<MAX;i++)
	{
		sum+=i;
		if(sum>n)
		{
			temp=i-1;
			sum-=i;
			break;
		}
	}

	for(i=0;i<temp-1;i++)
	{
		s[i]=2+i;
	}
	for(i=temp-2;i>=0;i--)
	{
		if(sum!=n)
		{		
			sum++;
			s[i]++;
		}
		else 
			break;
	}
	for(i=0;i<temp-1;i++)
	{
		cout<<s[i]<<' ';
	}
	cout<<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