| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1313 人关注过本帖
标题:怎样创建一个链表
取消只看楼主 加入收藏
浅暗花璃
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2016-3-31
结帖率:77.78%
收藏
已结贴  问题点数:6 回复次数:0 
怎样创建一个链表
怎样创建一个链表
struct student *create()
{
    struct student *head,*p1,*p2;
    int i=0,n;
    head=NULL;
    printf("plaese input n:");
    scanf("%d",&n);
    p1=((struct student *)malloc(sizeof(struct student)));
    p2=((struct student *)malloc(sizeof(struct student)));
    scanf("%d",&p1->num);
     //scanf("%s",p1->name);
     //fflush(stdin);
    // printf("plase input sex,f-女,m-男:");
    // scanf("%c",&p1->sex);
     //fflush(stdin);
     //scanf("%d",&p1->old);
    for(i=0;i<n;i++)
    {   
        if(i==0)
            head=p1;
        else{
             p1->next=NULL;
            p2->next=p1;
            p2=p1;
        }
   p1=(struct student *)malloc(sizeof(struct student));

    scanf("%d",&p1->num);
   }
  
   
    free(p1);
    return(head);

    }
搜索更多相关主题的帖子: create 
2016-06-02 19:45
快速回复:怎样创建一个链表
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011510 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved