Sign in

gwj / po_oopc · Files

GitLab

  • Go to dashboard
  • Project
  • Activity
  • Files
  • Commits
  • Network
  • Graphs
  • po_oopc
  • examples01-pl
  • 16-stack1
  • stack.c
  • Reformatted code
    c0b14c54
    Grzegorz Jabłoński authored
    2022-09-16 14:36:36 +0200  
    Browse Code »
stack.c 357 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include "stack.h"
#include <assert.h>

#define STACKSIZE 20
static int top; /* pierwsze wolne miejsce na stosie */
static int dane[STACKSIZE];

void init()
{
    top = 0;
}

void finalize() {}

void clear()
{
    top = 0;
}

void push(int a)
{
    assert(top < STACKSIZE);
    dane[top++] = a;
}

int pop()
{
    assert(top > 0);
    return dane[--top];
}