码迷,mamicode.com
首页 > 其他好文 > 详细

创建单链表并输出

时间:2017-10-13 21:18:09      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:etc   ret   style   typedef   输出   turn   getch   div   next   

#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;
注意这三句;

创建单链表并输出

标签:etc   ret   style   typedef   输出   turn   getch   div   next   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!