新人求助,一个读入多项式的问题
想通过下面这段程序读入多项式,可每次输入一项之后就自动退出了,求大神帮忙看看什么问题
struct polynomial{
int coef;
int expon;
struct polynomial* next;
};
int main(void)
{
int c,e,N;
scanf("%d", &N);
struct polynomial* P1;
struct polynomial* P2;
struct polynomial* temp1;
struct polynomial* temp2;
P1=malloc(sizeof(struct polynomial));
P2=malloc(sizeof(struct polynomial));
temp1=P1;
temp2=P2;
while(N--)
{
scanf("%d %d", &c, &e);
P1->next=malloc(sizeof(struct polynomial));
P1->next->expon=e;
P1->next->coef=c;
if(N=0)
{
P1->next->next=NULL;
P1=temp1;
}
else
P1=P1->next;
struct polynomial{
int coef;
int expon;
struct polynomial* next;
};
int main(void)
{
int c,e,N;
scanf("%d", &N);
struct polynomial* P1;
struct polynomial* P2;
struct polynomial* temp1;
struct polynomial* temp2;
P1=malloc(sizeof(struct polynomial));
P2=malloc(sizeof(struct polynomial));
temp1=P1;
temp2=P2;
while(N--)
{
scanf("%d %d", &c, &e);
P1->next=malloc(sizeof(struct polynomial));
P1->next->expon=e;
P1->next->coef=c;
if(N=0)
{
P1->next->next=NULL;
P1=temp1;
}
else
P1=P1->next;
...全文


