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

Re:谁能帮我看看,还有哪些要注意的?WA的不行了!代码附上!谢谢!

Posted by softmind at 2006-08-10 14:26:45 on Problem 1555
In Reply To:谁能帮我看看,还有哪些要注意的?WA的不行了!代码附上!谢谢! Posted by:softmind at 2006-08-10 14:26:34
#include <stdio.h>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
	
	char s[1000];
	while(cin.getline(s,1000)&&s)
	{		
		stringstream in(s);
		int pp[9]={0};
		for(int ii=8;ii>=0;ii--)				
				in>>pp[ii];	
		int i=8;
		while(pp[i]==0&&i)i--;
		if(pp[i]>0)
		{
			if(pp[i]==1&&i!=0)
				printf("x^%d",i);
			else if(i!=0)printf(" + %dx^%d",pp[i],i);
			else if(i==0&&pp[i])printf(" + %d",pp[i]);	
		}
		else
		{
			if(pp[i]==-1&&i!=0)
				printf("- x^%d",i);
			else if(i!=0)printf("- %dx^%d",abs(pp[i]),i);
			else if(i==0&&pp[i])printf("- %d",abs(pp[i]));
		}
		i--;
		for(;i>=0;i--)
		{
			if(pp[i]==0)continue;
			else if(pp[i]>0)
			{
				if(pp[i]==1&&i!=0)
					printf(" + x^%d",i);
				else if(i!=0)printf(" + %dx^%d",pp[i],i);
				else if(i==0&&pp[i])printf(" + %d",pp[i]);	
			}
			else
			{
				if(pp[i]==-1&&i!=0)
					printf(" - x^%d",i);
				else if(i!=0)printf(" - %dx^%d",abs(pp[i]),i);
				else if(i==0&&pp[i])printf(" - %d",abs(pp[i]));
			}
			
		}
		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