对单链表使用双重for循环出现特定语句就无法进行循环
#include<stdio.h>#include<string.h>
#include<stdlib.h>
typedef float DataType;
typedef struct linknode
{
DataType data1;
DataType data2;
struct linknode *next;
}LinkList;
void main()
{
float a,n,x,sum=0;
int key=1,m=0,j=0,z,k;
LinkList *s,*last,*head1,*head2,*head3,*p1,*p2,*p3,*t;
head1=(LinkList *)malloc(sizeof(LinkList));
head2=(LinkList *)malloc(sizeof(LinkList));
head3=(LinkList *)malloc(sizeof(LinkList));
p1=(LinkList *)malloc(sizeof(LinkList));
p2=(LinkList *)malloc(sizeof(LinkList));
p3=(LinkList *)malloc(sizeof(LinkList));
last=head1;
while(key==1)
{
printf("一一输入第一个函数式的系数、指数和(继续输入指令1或停止输入指令0),用逗号隔开。\n输入函数1数据中\n");
scanf("%f,%f,%d",&a,&n,&key);
t=(LinkList *)malloc(sizeof(LinkList));
t->data1=a;t->data2=n;
t->next=NULL;
last->next=t;
last=t;
m++;
}
last=head2; key=1;
while(key==1)
{
printf("一一输入第二个函数式的系数、指数和(继续输入指令1或停止输入指令0),用逗号隔开。\n输入函数1数据中\n");
scanf("%f,%f,%d",&a,&n,&key);
s=(LinkList *)malloc(sizeof(LinkList));
s->data1=a;s->data2=n;
s->next=NULL;
last->next=s;
last=s;
j++;
}
p1=head1->next;
p2=head2->next;
printf("f(x)=");
for(z=1;z<=m;z++)
{sum=0;sum+=p1->data1;x=p1->data2;
for(k=1;k<=j;k++)
{
if(x==p2->data2)
sum+=p2->data1;p2=p2->next;
}
p1=p1->next;
printf("+(%6.1fx^%6.1f)",sum,x);
}
}求大佬救命