#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 20

struct complex {
    int re;
    int im;
};

struct stos {
    int sp;
    struct complex tab[N];
};

void init(struct stos*);
int isEmpty(struct stos*);
int isFull(struct stos*);
struct complex* pop(struct stos* k);
void push(struct complex x, struct stos* k);


int main()
{
    struct stos l;
    struct complex bb;
    int i;
    init (&l);
    bb.re=2;
    bb.im=1;
    push(bb,&l);
    for (i=0;i<N;i++)
    {
        printf("%i +j%i\n",l.tab[i].re,l.tab[i].im);
    }
    pop(&l);
    return 1;
}
void init(struct stos* k)
{
    k->sp=0;
    memset(k->tab,0,N*sizeof(struct complex));
}

int isEmpty(struct stos* k)
{
    if (k->sp==0) return 1;
    else return 0;
}

int isFull(struct stos* k)
{
    if (k->sp>=N) return 1;
    else return 0;
}

void push(struct complex x, struct stos* k)
{
    if (isFull(k)) printf ("Stos jest pelny\n");
    else {
   // k->tab[k->sp].im = x.im;
   // k->tab[k->sp].re = x.re;
   k->tab[k->sp]=x;
    k->sp++;
    }
}

struct complex* pop(struct stos* k)
{
    struct complex* x = (struct complex*)malloc(sizeof(struct complex));
    if (isEmpty(k)) {
    printf ("Stos jest pusty\n");
    return NULL;}
    else{
    x->im = k->tab[k->sp].im;
    x->re = k->tab[k->sp].re;
    k->sp--;
    }
    printf ("%i, %i", x->re,x->im);
    return x;
}