• 数据结构笔记2链栈


    #include<stdio.h>
    #include<conio.h>
    #include<malloc.h>
    #define MAX 100
    struct node{
     int data;
     struct *next;
    }s;
    //初始化 
    int InitStack(&s){
     s=(node *)malloc(sizeof(node));
     if(NULL==s)
      return -1;
     s->next=NULL;
    }
    //判空
    int StackEmpty(&s){
     if(NULL==s->next)
      return 1;
     return 0;

    //求长度
    int StackLength(&s){
     int count=0;
     node *p=s;
     while(NULL!=p->next){
      p=p->next;
      count++;
     }
     return count;

    //访问栈顶 
    int GetTop(&s,int *e){
     if(StackEmpty(*s))
      return -1;
     *e=s->next->data;
     return 0;
    }
    //入栈
    int Push(&s,int e){
     node *p;
     p=(node *)malloc(sizeof(node));
     if(p==NULL)
      return -1;
     p->data=e;
     p->next=s->next;
     s->next=p;
     return 0;

    //出栈 
    int Pop(&s,int *e){
     node *p=NULL;
     if(StackEmpty(*s))
      return -1;
     p=s->next;
     *e=p->data;
     s->next=p->next;
     free(p);
     return 0;
    }
    //主函数
    int main(){
     
    }

  • 相关阅读:
    supervisor管理airflow
    airflow迁移
    flume部署
    canal原理&部署
    EMR日常操作
    linux的route
    autossh
    Velocity(5)——#macro 指令
    Git(1)----Eclipse安装Git插件
    Velocity(4)——引入指令和#Parse 指令
  • 原文地址:https://www.cnblogs.com/100114jerro/p/4998735.html
Copyright © 2020-2023  润新知