首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

2个炼表数据相加。哪错了,该如何解决

2012-03-09 
2个炼表数据相加。。哪错了structnum{intiintjstructnum*next}for(p1g1p1- next!NULLp1p1- next)

2个炼表数据相加。。哪错了
struct   num
{
int   i;
int   j;
struct   num   *next;
};


for(p1=g1;p1-> next!=NULL;p1=p1-> next)
      {
      for(p2=g2;p2-> next!=NULL;p2=p2-> next)
      {
      k=p1-> j;
      if(p1-> i==p2-> i)
      {
      p3-> i=p1-> i;
      p3-> j=p1-> j+p2-> j;
                              t=(struct   num*)malloc(sizeof(struct   num));
      t-> next=NULL;
      p3-> next=t;
      p3=t;
      continue;

      }

      }
      if(p2-> next==NULL&&k==p1-> j)
      {
      p3-> i=p1-> i;
              p3-> j=p1-> j;
      }
      while(p3-> next!=NULL)
      {
      printf( "%dx^%d+ ",p3-> j,p3-> i);
      }


[解决办法]
在你的程序中,
是否存在这样的 预设条件:
g1 多项式中,最高次方 要高于 g2多项式中的最高次方?

否则,
g2 中的最高次方数据就丢失了 ~

热点排行