|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
void main ()
{
struct student *creat(struct student *head); //链表建立函数
struct student *del(struct student *head,int num); //链表删除函数
struct student *insert(struct student *head,struct student *stu); //链表插入函数
void print(struct student *head); //链表打印函数
int m;
struct student *head,*stu;
head=NULL;
head=creat(head);
print(head);
printf("\n");
printf("Please input the num you want to delete:");
scanf("%d",&m);
printf("\n");
print(del(head,m));
printf("\n");
stu=(struct student *)malloc(sizeof(struct student));
printf("Please input the num you want to insert:");
scanf("%d",&stu->num);
printf("Please input the score you want to insert:");
scanf("%d",&stu->score);
#if(1)
while(stu->num!=0)//实现多次插入!
{
printf("\n");
head=insert(head,stu);
print(head);
stu=NULL;
stu=(struct student *)malloc(sizeof(struct student));//重新向系统申请分配节点;
printf("Please input the num you want to insert:");
scanf("%d",&stu->num);
printf("Please input the score you want to insert:");
scanf("%d",&stu->score);
}
#else
printf("\n");
head=insert(head,stu);//实现单次插入
print(head);
#endif
} |
评分
-
查看全部评分
|