双向循环链表程序运行弹出了name.exe已停止工作对话框,然后下面有调试停止这些选项
程序如下:才刚写了一个创建的函数,用P指针开拓节点,q记录最后开拓的节点,head是头结点
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
static int n=0;
struct node
{
int num;
int score;
struct node *next;
struct node *prior;
};
struct node *creat()
{ struct node *head;
struct node *p,*q;
head=NULL;
p=q=(struct node *)malloc(sizeof(struct node));
printf("第%d个学生信息:\n",++n);
printf("学号:");
scanf("%d",&p->num);
while(p->num != 0)
{
printf("成绩:");
scanf("%d",&p->score);
if(head=NULL)
head=p;
if(head!=NULL)
{
q->next=p;
p->prior=q;
q=p;
}
p=(struct node*)malloc(sizeof(struct node));
printf("第%d个学生信息:\n",++n);
printf("学号:");
scanf("%d",&p->num);
}
n--;
q->next=head;
head->prior=q;
free(p);
printf("创建成功\n");
return(head);
}
void main()
{
creat();
}