C语言实现顺序栈

2021-06-07 12:03

阅读:434

标签:==   col   c语言   nbsp   number   ber   define   int   实现   

#include #define NUMBER 100

int push(int* a, int top, int data)
{
    a[++top] = data;
    return top;
}

int pop(int* a, int top)
{
    if (top == -1) {
        return -1;
    }
    printf("%d\n",a[top]);
    top--;
    return top;
}

int main()
{
    int a[NUMBER];
    int top = -1;
    top = push(a, top, 1);
    top = push(a, top, 3);
    top = push(a, top, 5);

    top = pop(a, top);
    top = pop(a, top);
    top = pop(a, top);

    return 0;
}

 

C语言实现顺序栈

标签:==   col   c语言   nbsp   number   ber   define   int   实现   

原文地址:https://www.cnblogs.com/zgen1/p/14585250.html


评论


亲,登录后才可以留言!