Beruflich Dokumente
Kultur Dokumente
Conectarea Pinilor {
if(Stack!=NULL)
#include <iostream>
{
#include <cstring>
nod* aux = Stack;
using namespace std;
Stack = Stack ->next;
struct nod
delete aux;
{
}
int info;
else cout<<"Stiva vida\n";
nod *next;
}
};
bool empty(nod*Stack)
void push(int val, nod*& Stack)
{
{
if (Stack == NULL) return 1;
nod* aux = new nod;
return 0;
aux->info = val;
}
aux->next = NULL;
int peek(nod* Stack)
if (Stack == NULL)
{
Stack = aux;
if(Stack != NULL) return Stack->info;
else
}
{
aux->next = Stack;
int main()
Stack = aux;
{
}
nod* Stack = NULL;
}
int pereche[100],n,i;
void pop(nod*& Stack)
cin>>n;
for(int i=0; i<n; i++) push(pereche[i],Stack);
cin>>pereche[i]; }
for(int i=0; i<n; i++) if (empty(Stack))
{ cout<<"Configuratie valida";
if(empty(Stack)) // Stiva e vida else cout<<"Configuratie invalida";
push(pereche[i],Stack); return 0;
else if(pereche[i] == peek(Stack)) }
pop(Stack);
else