| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
两个多项式相加,求解啊!程序写出来了,老出错,求解!谢谢!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator