帮忙看下
程序目的是把a链表中与b链表学号相同的学生删去,但是这样这法达不到效果,为什么??#define NULL 0
struct student
{int num;
char name[10];
struct student *next;
}a[5],b[5];
main()
{struct student a[5]={{101,"Wang"},{102,"Li"},{105,"Zhang"},{106,"Wei"}};
struct student b[5]={{103,"Zhang"},{104,"Ma"},{105,"Chen"},{107,"Guo"},{108,"Lui"}};
int i,j;
struct student *head;
head=a;
for(j=0;j<5;j++)
for(i=0;i<5;i++)
{if(a[i].num==b[j].num)
if(i==0)
{head=a[i].next;
a[i].next=NULL;
}
else
{a[i-1].next=a[i].next;
a[i].next=NULL;
}
}
printf("\nresult:\n");
i=0;
while(a[i].num!=NULL)
{printf("%7d%7s\n",a[i].num,a[i].name);
i++;
}
}