求校正。。。> <谢谢
#include<stdio.h>#include<stdlib.h>
#include<malloc.h>
#define ElemType int
typedef struct student
{ElemType num;
char name[20];
char sex[10];
char addr[20];
struct student*next;
}Student;
void outlin(student*h);
void creat();
void insert(Student*h);
void delet(Student*h,int x);
Student*p,*q,*s,*head;
void creat()
{
ElemType x1;
Student*ptr;
head=(Student*)malloc(sizeof(Student));
p=head;
head->next=NULL;
char x2,x3,x4;
while(x1!='0')
{
printf("\n 学号,姓名,性别,地址");
ptr=(Student*)malloc(sizeof(Student));
char x2,x3,x4;int x1;
ptr->num=x1;
ptr->name[20]=x2;
ptr->sex[10]=x3;
ptr->addr[20]=x4;
p->next=ptr;
ptr->next=NULL;
p=ptr;
scanf("%d,%s,%s,%s\n",&x1,&x2,&x3,&x4);
}
printf("\n 学号,姓名,性别,地址=%d,%s,%s,%s",x1,x2,x3,x4);
}
void outlin(Student *h)
{
p=h->next;
printf("\n ");
while(p!=NULL)
{
printf("num=%10dname=%20ssex=%10saddr=%20s",p->num,p->name,p->sex,p->addr);
p=p->next;
}
printf("输出结果\n\n");
}
void insert(Student*h)
{
printf("num=?\n");
int x;
scanf ("%d",&x);
printf("num=%d\n",x);
s=(struct student*)malloc(sizeof(struct student));
char y2,y3,y4;
int y1;
s->num=y1;
s->name[20]=y2;
s->sex[10]=y3;
s->addr[20]=y4;
q=h;
p=h->next;
while(p!=NULL&&p->num!=x)
{
q=p;
p=p->next;
}
q->next=s;
s->next=p;
}
void delet(Student*h, ElemType x1)
{
Student *q;
p=h;
while(p->next==NULL&&p->next->num!=x1)
p++;
if(p->next==NULL)
printf("\n x 不存在 !");
else{q=p->next;
p->next=q->next;
free(q);
}
}
int main()
{int i,x,y,cord;
do{printf("\n 主菜单 \n");
printf(" 1 建立线性表 \n");
printf(" 2 插入一个元素 \n");
printf(" 3 删除一个元素 \n");
printf(" 4 结束程序运行 \n");
printf("----------------------\n");
printf(" 请输入您的选择(1,2,3,4)");
scanf("%d",&cord);
switch(cord)
{
case 1:{creat();outlin(head);}break;
case 2:{printf("\n x4,y1,y2,y3,y4=?注意用逗号分隔");
char y1, y2,y3,y4,x4;
scanf("%s,%d,%s,%s,%s",&x4,&y1,&y2,&y3,&y4);
insert(head);
outlin(head);}break;
case 3:{printf("\nx=?");
scanf("%d",&x);
delet(head,x);
outlin(head);}break;
case 4:exit(0);
default:printf("输入数据有误");
}
}while(cord<=4);
}