zoukankan      html  css  js  c++  java
  • c数据结构 -- 使用链表实现计数

    #include <stdio.h>
    #include <stdlib.h>
    typedef struct _node{
        int value;
        struct _node *next;
    } Node;
    int main(void)
    {
        Node * head = NULL;
        int num,i;
        i =0;
        do{
            scanf("%d",&num);
            if(num != -1){
                Node *p = (Node*)malloc(sizeof(Node));
                p->value = num;
                p->next = NULL;
                // find the last
                if(i != 0){
                    Node *last = head;
                    while(last->next){
                        last = last->next;
                    }
                    last->next = p;
                }else{
                    head = p;
                }
                i++;
            }
        }while(num != -1);
        
        do{
            printf("数字:%d",head->value); 
            head = head->next;    
        }while(head);
        
        return 0;
    }
  • 相关阅读:
    哈夫曼树
    MongoDB
    Node.js 搭建Web
    Node.js
    HDFS编程
    scp
    MapRecude
    级数
    (转)MySQL百万级数据库优化
    ssh
  • 原文地址:https://www.cnblogs.com/cl94/p/12236381.html
Copyright © 2011-2022 走看看