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 1023015455 at 2012-03-11 17:02:18
typedef struct
{
	int coeffarray[maxdegree+1];
	int highpower;
}*polynomial;

void zeropolynomial(polynomial poly)
{
	int i;
	for(i=0;i<=maxdegree;i++)
		poly->coeffarray[i]=0;
	poly->highpower=0;
}

void addpolynomial(const polynomial poly1,const polynomial poly2,polynomial polysum)
{
	int i;
	zeropolynomial (polysum);
	polysum->highpower=max(	poly1->highpower,poly2->highpower);
    for(i=polysum->highpower;i>=0;i--)
		polysum->coeffarray[i]=poly1->coeffarray[i]+poly2->coeffarray[i];
}

int max(int a,int b)
{
	if(a>b) return a;
	else
		return b;
}

void main()
{
	polynomial p1,p2,p;
	printf ("%d\n,"addpolynomial(p1,p2,p));
}



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