Cod sursa(job #2421599)

Utilizator AndreiJJIordan Andrei AndreiJJ Data 15 mai 2019 12:40:18
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.9 kb
#include <iostream>
#include <climits>

using namespace std;

struct nod
{
    int info;
    nod *leg;
    nod (int x) ///constructor
    {
        info = x;
        leg = NULL;
    }
};

struct Stiva
{
    nod *top;
    void Init ()
    {
        top = NULL;
    }
    bool Empty ()
    {
        return (top == NULL);
    }
    void Push(int x)
    {
        nod *p;
        p = new nod (x);
        p -> leg = top;
        top = p;
    }
    void Pop ()
    {
        if (Empty())
            return;
        nod *p = top;
        top = top -> leg;
        delete p;
    }
    int Top ()
    {
        if (Empty())
            return -INT_MAX;
        return top -> info;
    }
    int Size ()
    {
        int cnt = 0;
        for (nod *p = top; p != NULL; p = p -> leg)
            cnt++;
        return cnt;
    }
};

int main()
{

    return 0;
}