鱼C论坛

 找回密码
 立即注册
查看: 2732|回复: 5

[技术交流] 小甲鱼老师视频:结构与共同体06链表多次插入主函数实现部分

[复制链接]
发表于 2012-7-28 16:40:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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   
}

评分

参与人数 1荣誉 +5 鱼币 +2 贡献 +2 收起 理由
旋风0级 + 5 + 2 + 2

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-7-28 18:44:29 | 显示全部楼层
拿钱来的。。。。。。。。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-8-10 19:40:59 | 显示全部楼层
:D:D高手啊
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2019-4-11 19:12:36 | 显示全部楼层
这个为什么会循环输出呢,在视频里面
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2022-2-7 21:03:33 | 显示全部楼层
C语言小跟班 发表于 2019-4-11 19:12
**** 作者被禁止或删除 内容自动屏蔽 ****

同问
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-2-7 21:05:53 | 显示全部楼层
这个为什么会循环输出呢,在视频里面
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-17 02:55

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表