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

怎么总是Presentation Error,那为朋友帮我看看!

Posted by 21127149 at 2006-08-12 14:36:02 on Problem 1555
#include"stdio.h"
#include"stdlib.h"
int coefficient[9];
scan(int *a)
{
	int i;

	for(i=0;i<9;i++)
	{
		if(scanf("%d",&a[i])<=0)
			return 0;
	}
	return 1;
}
int main()
{
	int i,k;
	while(scan(coefficient))
	{
		for(k=0;k<9;k++)
		{
			if(coefficient[k]!=0)
				break;
		}
		if(k<8)
		{
			if(k<7)
			{
			if(coefficient[k]>1)
				printf("%dx^%d",coefficient[k],8-k);
			else
				if(coefficient[k]==1)
					printf("x^%d",8-k);
				else
					if(coefficient[k]==-1)
						printf("-x^%d",8-k);
					else
						if(coefficient[k]!=0)
							printf("%dx^%d",coefficient[k],8-k);
			}
			for(i=k+1;i<7;i++)
			{
				if(coefficient[i]>1)
					printf(" + %dx^%d",coefficient[i],8-i);
				else
					if(coefficient[i]==1)
						printf(" + x^%d",8-i);
					else
						if(coefficient[i]==-1)
							printf(" - x^%d",8-i);
						else
							if(coefficient[i]!=0)
								printf(" - %dx^%d",coefficient[i]*(-1),8-i);
			}
			if(coefficient[7]>1)
				printf(" + %dx",coefficient[7]);
			else
				if(coefficient[7]==1)
					printf(" + x");
				else
					if(coefficient[7]==-1)
						printf(" - x");
					else
						if(coefficient[i]!=0)
							printf(" - %dx",coefficient[7]*(-1));
		}
		if(k==9)
			printf("0");
		else
		{
		if(k==8)
			printf("%d",coefficient[8]);
		else
			if(coefficient[8]>0)
				printf(" + %d",coefficient[8]);
			else
				if(coefficient[8]!=0)
					printf(" - %d",coefficient[8]*(-1));
		}
		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