zoukankan      html  css  js  c++  java
  • 【c语言】【每周一练】整数队列实现

    #include <stdio.h>
    struct node{
        int number;
        struct node * next;
    };
    void Init_list(struct node *root);
    void Push_list(struct node *p,struct node *root);void Pop_list(struct node *root);
    struct node* Get_list(struct node *root);
    void Print_list(struct node *root);
    
    
    int main(void){
        struct node head,a,b,*p;
        a.number=1;
        b.number=2;
        Init_list(&head);
        Push_list(&a,&head);
        Push_list(&b,&head);
        Print_list(&head);
        Pop_list(&head);
        p=Get_list(&head);
        Print_list(&head);
        printf("%d\n",p->number);
        Print_list(&head);
    }
    void Init_list(struct node *root){
        root->next=0;
        root->number=0;
    }
    void Push_list(struct node *p,struct node *root){
        struct node *head=root;
        while(head->next!= 0 ){head=head->next;}
        head->next=p;root->number++;
        p->next=0;
    }
    void Pop_list(struct node *root){
        
    if(root->next!=0)
    root->next=root->next->next;
    root->number--;
    }
    
    struct  node*  Get_list(struct node *root){
    return root->next;
    }
    
    void Print_list(struct node *root){
        struct node *head=root;
    printf("队列共有%d个元素\n",head->number);
    while(head->next!=0){
        head=head->next;    
    printf("%d\n",head->number);
    }
    }

    每周一练,day day up!


     

  • 相关阅读:
    入门指引之永久素材
    入门指引之上传临时素材
    入门指引之查看accesstoken
    java中的左移 右移
    病狗问题
    leetcode 几何题 位运算 面试编程
    CNN网络参数
    python学习整理
    JAVA问题整理
    计算机网络整理
  • 原文地址:https://www.cnblogs.com/huals/p/2501344.html
Copyright © 2011-2022 走看看