首页 > 其他 > 详细

创建单链表并输出

时间:2017-10-13 21:00:41      阅读:286      评论:0      收藏:0      [点我收藏+]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Note
{
    char a;
    struct Note* next;
} Note,*list;a
void CF(list L)
{
    Note *s;
    char c;
    int flag = 1;
    while(flag)
    {
        c = getchar();
        getchar();
        if(c != $)
        {
            s=(Note*)malloc(sizeof(Note));
            s->a=c;
            s->next=L->next;
            L->next=s;
        }
        else 
            flag = 0;
    }
}
int main()
{
    list L,s;
    L=(Note*)malloc(sizeof(Note));
    L->next=NULL;
    CF(L);
    s=L->next;
    while(s->next!=NULL)
    {
        printf("%c ",s->a);
        s=s->next;
    }
    printf("%c\n",s->a);
    return 0;
}
            s->a=c;
            s->next=L->next;
            L->next=s;
注意这三句;

创建单链表并输出

原文:http://www.cnblogs.com/a595452248/p/7662865.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!