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 chanma at 2005-09-19 15:37:59 on Problem 2527
#include <stdio.h>

int first[10001];

int main()
{
	int n,k,i,j;
	while(scanf("%d%d",&n,&k))
	{
		if(n==-1&&k==-1)
			break;
		for(i=0;i<=n;++i)
			scanf("%d",&first[n-i]);
		if(k==0)
		{
			printf("%d\n",0);
			continue;
		}
		for(i=0;i<=n-k;++i)
		{
			if(first[i]==0)
				continue;
			first[i+k]-=first[i];
			first[i]=0;
		}
		for(j=n-k+1;j<n;++j)
		{
			if(first[j]!=0)
				break;
		}
		for(i=n;i>=j;--i)
		{
			printf("%d",first[i]);
			if(i>j) printf(" ");
			else printf("\n");
		}
	}
	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