美文网首页
静态链表

静态链表

作者: 始于尘埃 | 来源:发表于2019-06-27 20:49 被阅读0次

    /*
    静态链表
    @author by Rice
    */

    #include <iostream>
    using namespace std;
    
    struct Lnode{
        int data;
        char name[10];
        struct Lnode *next;
    };
    int main(){
        struct Lnode a,b,c,*p,*Head;
        int x;
        //初始化
        Head = NULL;
        Head = &a;
        a.next = &b;
        b.next = &c;
        c.next = NULL;
        p = Head;
        //创建
        
        while(p!=NULL){
            scanf("%d",&x);
            p->data = x;
            p = p->next;
        }
        
        //输出
        p = Head;
        while(p!=NULL){
            printf("%d\n",p->data);
            p = p->next;
        }
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:静态链表

          本文链接:https://www.haomeiwen.com/subject/qqydcctx.html