| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 385 人关注过本帖
标题:[求助]找错,谢谢
取消只看楼主 加入收藏
风中枫叶
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-24
收藏
 问题点数:0 回复次数:1 
[求助]找错,谢谢

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-06-29 11:14
风中枫叶
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-6-24
收藏
得分:0 
就是看一下那个循环有没有错

男子汉,大丈夫,就应该找个女的温柔温柔!^_^ 有时间来这里看看: http://blog./user1/104/
2006-06-29 11:55
快速回复:[求助]找错,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053254 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved