用单链表存储多项式,写完了但是运行不了..老是出现这个错误,怎么改都不行.求大神指教
这是程序原文:#include <iostream>
#include <string>
using namespace std;
typedef struct node * pointer;
struct node{
int co; //系数
int exp;//指数
struct node * next ;
};
typedef pointer lklist;
lklist node()
{
pointer head,rear,s;
int co;
int exp;
head=new node;
rear=head;
for(i=0;i<n;i++)
{s=new node;
cin>>s->co;
cin>>s->exp;
rear->next=s;
rear=s;
cout<<endl;
}
rear->next=NULL;
return head;
}
void output(lklist head)
{pointer p;
p=head->next;
while(p->next)
{cout<<p->co<<"*x"<<p->exp<<endl;
}}
node * creat(node*head,int x)
{node*s;s=head->next;
while(s&&s->exp!=x)
{s=s->next;}
return s ;}
lklist add(lklist A,lklist B)
{pointerc,p,q,r;
q=B->next;
c=A;
while(q!=NULL)
{if(p=locate(a,q->exp))
{p->co=p->co+q->co;p->exp=p->exp;
q=q->next;}
else {r=new node;
r->co=q->co;
r->exp=q->exp;
r->next=c->next;
c->next=r;
q=q->next;}
return c;}
int main()
{lklist A,B,C;
A=creat();cout<<"A:";output(A);
B=creat();cout<<"B:";output(B);
c=add(A,B);
cout<<"C=A+B"<<endl<<"C:";output(C);
return 0;
}
出现的错误是:C:\Documents and Settings\Administrator\桌面\5.cpp(26) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Administrator\桌面\5.cpp(26) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Administrator\桌面\5.cpp(26) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Administrator\桌面\5.cpp(26) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Administrator\桌面\5.cpp(26) : fatal error C1003: error count exceeds 100; stopping compilation