Pagini recente » Cod sursa (job #599621) | Cod sursa (job #34253) | Cod sursa (job #3165244) | Cod sursa (job #1836406) | Cod sursa (job #2421599)
#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;
}