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 peng494563814 at 2010-03-21 19:23:34 on Problem 1032
#include<stdio.h>
int main()
{
	int n,i,j,a[50];
	scanf("%d",&n);
    for(i=2;n>=i;i++)
	{
		a[i-2]=i;
		n-=i;
	}
	
	for(j=49;j>=0;j--)
	{
		if(a[j]>0&&n>0)
		{
            a[j]++;n--;
		}
	}

	if(n>0)
	{
         for(j=49;j>=0;j--)
		    if(a[j]>0&&n>0)
                 a[j]++;n--;
	}
	for(i=0;i<49&&a[i]>0;i++)
		printf("%d ",a[i]);
	puts("");
	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