POLY *exception(ha,hb)
POLY *ha,*hb;
{
POLY *hc,*pA,*pB,*pAp,*pC,*pCp,*pT,*pD;
int COUNT=0;
hc=NEW;
hc->next=hc;
pCp=hc;
while(1)
{
COUNT++;
pC=NEW;
pAp=ha;
ha->coef=-9999999;
ha->exp=-9999999;
pA=pAp->next;
pB=hb->next;
if(pA->exp>=pB->exp)
{
pC->exp=pA->exp-pB->exp;
pC->coef=pA->coef*pB->coefs;
pC->coefs=pA->coefs*pB->coef;
}
else
{
free(pC);
break;
}
pCp->next=pC;
pCp=pCp->next;
pCp->next=hc;
pD=pA;
pA=pA->next;
pAp->next=pA;
pB=pB->next;
free(pD);
while(pB!=hb)
{
if(pA->exp>(pB->exp+pC->exp))
{
while(pA->next->exp>(pB->exp+pC->exp))
pA=pA->next;
if(pA->next->exp==(pB->exp+pC->exp))
{pA->next->coef=pA->next->coef-(pB->coef*pC->coef);
if(pA->next->coef==0)
{
pD=pA->next;
pA->next=pA->next->next;
free(pD);
}
}
else
{
pT=NEW;
pT->exp=pB->exp+pC->exp;
pT->coef=-pB->coef*pC->coef;
pT->coefs=pB->coefs*pC->coefs;
pT->next=pA->next;
pA->next=pT;
}
pA=pAp->next;
}
else if(pA->exp==(pB->exp+pC->exp))
{
pA->exp=pA->exp;
pA->coef=pA->coef*pB->coefs*pC->coefs-pA->coefs*pB->coef*pC->coef;
pA->coefs=pA->coefs*pB->coefs*pC->coefs;
}
else if(pA->exp<(pB->exp+pC->exp))
{
pT=NEW;
pT->exp=pB->exp+pC->exp;
pT->coef=-pB->coef*pC->coef;
pT->coef=-pB->coefs*pC->coefs;
pT->next=pA; /*copy *pB to ha*/
pAp->next=pT;
pAp=pT;
}
if(pA->coef==0)
{
pD=pA;
pA=pA->next;
pAp->next=pA;
free(pD);
}
else
{
pAp=pA;
pA=pA->next;
}
pB=pB->next;
}
pB=hb->next;
pA=ha->next;
pAp=ha;
printf("This is the %d turn\n",COUNT);
printf("The result poly is:\n");
print_poly(hc);
printf("The poly A is:\n");
print_poly(ha);
}
return(hc);
}
----------------解决方案--------------------------------------------------------
什么都没有。找个毛呀
就连头文件都米!
还很混乱哟~~~
[此贴子已经被作者于2006-6-29 11:28:59编辑过]
----------------解决方案--------------------------------------------------------
就是看一下那个循环有没有错
----------------解决方案--------------------------------------------------------
头都大了。先运行下然后把错误的行标注下然后发出来。光这样看你发出来的实在看的眼睛都花!
----------------解决方案--------------------------------------------------------