大家帮忙找下错
本人用链表 算2个一元多次方程向加的结果#include<stdio.h>
#include<stdlib.h>
typedef struct a{
struct a *next;
int z;
int x;
}b;
int initiate(b **p) /*声明头结点*/
{
if((*p=(b *)malloc(sizeof(b)))==NULL)return 0;
else (*p)->next=NULL; return 1;
}
void insert(b *h) /*插入结点*/
{
b *s,*o;
int i,k,j,g;
o=h; /*j xishu*/
scanf("%d",&k);
printf(" now you have enter %d number\n",k);
for(i=0;i<k;i++)
{
printf("the %d number: ",i+1);
scanf("%d %d",&j,&g);
s=(b *)malloc(sizeof(b));
s->x=j;s->z=g;s->next=NULL;
o->next=s;
o=s;
}
}
void shuchu(b *h) /*输出链表*/
{
b *o,*c;
o=h->next;
printf("qian wei xishu hou wei zhishu");
while(o!=NULL)
{
printf("%d%d ",o->x,o->z);
o=o->next;
}
}
void hebing(b *p,b *q) /*将俩链表相加*/
{
b *l,*u,*f,*g; /* g 释放 l定位*/
u=p->next;f=q->next;
l=p;
while(f!=NULL&&u!=NULL)
{
if(u->z==f->z)
{
if(u->x+f->x==0)
{
g=u; l->next=u->next; u=u->next;free(g);
g=f; f=f->next;free(g);
}
else
{
u->x=(u->x+f->x); l=u;u=u->next;f=f->next;
}
}
elseif((u->z)>(f->z)) /*11111111111111111111111111*/
{
g=f; g=g->next;
f->next=l->next; l->next=f;l=f;
f=g;
}
else
{l=u; u=u->next; }
}
if(u==NULL){
u=f;
}
}
main()
{
b *h1,*h2;
int x,y,m,n,k,i;
printf("now we bigain the *head");
if(initiate(&h1)==0){printf("now we are fail the first one"); exit(0);}
if(initiate(&h2)==0){printf("now we are fail the second one"); exit(0);}
printf("enter the first line how many do you want insert please enter with space the first is xishu\n");
insert(h1);
printf("enter the sencond line how many do you want insert\n");
insert(h2);
printf("now putout the two line");
printf("/*****************************/\n");
shuchu(h1);
printf("/****************************/\n");
shuchu(h2);
printf("/*****************************/\n");
printf("now hebing duoxiangshi");
hebing(h1,h2);
shuchu(h1);
}
最终链表的结果 记在h1上
错误提示 statement missing ; in function hebing
但我并没找到哪个地方缺少;
错误位置在我打/*11111111111111111111111111*/的那行