已经检查几次,找不到错误,麻烦大神帮我看一下,谢谢
#include <stdio.h>#include <stdlib.h>
typedef struct polynode
{
int coef;//系数域
int exp;//指数域
struct polynode *next;
}PNode;
PNode *Creat_Linkst (int n);
void Print_Linkst (PNode *H);
main()
{
PNode *pa;//多项式单链表的头指针
int num;//多项式项数
printf("enter num");
scanf("%d",&num);//建立多项式
pa=Creat_Linkst(num);
printf("A(x)=");
Printf_Linkst(pa);
getch();
}
void Printf_Linkst(PNode *H)
{
PNode *p;
p=H->next;
while(p->next)
{
printf("%dx^%d+",p->coef,p->exp);
p=p->next;
}
if(p->exp)
printf("%dx^%d\n",p->next,p->exp);
else
printf("%d\n",p->coef);
}
PNode *Creat_Linkst(int n)
{
PNode *head,*p,*s;
int i;
head=(PNode *)malloc(sizeof(PNode));
head->next=0;
p=head;
printf("enter coef,exp:\n");
for(i=1;i<=n;++i)
s=(PNode *)malloc(sizeof(PNode));
scanf("%d,%d",&s->coef,&s->exp);
s->next=0;
p->next=s;
p=s;
}
return (head);
}