#include <iostream>
using namespace std;
struct node {
int val;
node* next;
};
bool is_Empty(node*stack);
void enqueue(node *&Q,node *&T,int x)
{
node*p =new node;
p->val=x;
p->next=NULL;
if(Q==NULL)
Q=p;
else
T->next=p;
T=p;
}
void dequeue(node*&Q,node *&T)
{
if(Q!=NULL)
{
node *p=Q;
Q=Q->next;
delete p;
}
if(Q==NULL)
T=NULL;
}
void showfirst(node* Q)
{
if(Q!=NULL){
node *p = Q;
cout<<p->val;
}
}
void showlast(node* T)
{
if(T!=NULL){
node *p = T;
cout<<p->val;
}
}
bool is_Empty(node*Q) //t-next=new node; t=t-next; t-val=x; t-next=null; - to ->
{
if(Q==NULL)
return true;
else
return false;
}
int main()
{
node* Q = NULL;
node* T=NULL;
enqueue(Q,T, 2);
enqueue(Q,T, 5); //zad przerzucanie stosu na kolejke (co 2 element )//
//zadanie 2 przerzucanie z kolejki na stos (co 2 element )
cout << "gora kolejki";
showfirst(Q);
enqueue(Q,T, 6);
dequeue(Q,T);
cout<<endl;
cout << "gora kolejki";
showfirst(Q);
cout << "dol kolejki";
showlast(T);
system("pause");
}
/stos
#include <iostream>
using namespace std;
struct node {
int val;
node* next;
};
bool is_Empty(node*stack);
void enqueue(node *&Q,node *&T,int x)
{
node*p =new node;
p->val=x;
p->next=NULL;
if(Q==NULL)
Q=P;
else
T->next=P;
T=P;
}
void dequeue(node*&Q,node *&T)
{
if(Q!=NULL)
{
node *p=q;
Q=Q->next;
delete p;
}
if(Q==NULL)
T=NULL;
}
void showfirst(node* Q)
{
if(Q!=NULL){
node *p = Q;
cout<<p->val;
}
}
bool is_Empty(node*Q) //t-next=new node; t=t-next; t-val=x; t-next=null; - to ->
{
if(Q==NULL)
return true;
else
return false;
}
void push(node*&stack, int x)
{
node* p = new node;
p->val = x;
p->next = stack;
stack = p;
}
int pop(node *stack)
{
if(is_Empty)
{
cout<<"stos jest pusty";
}
else
{
node*p=stack;
return (p->val);
}
}
void showtop(node *stack)
{
if(stack!=NULL){
node *p = stack;
cout<<p->val;
}
}
bool is_Empty(node*stack) //t-next=new node; t=t-next; t-val=x; t-next=null; - to ->
{
if(stack==NULL)
return true;
else
return false;
}
int main()
{
node* stack = NULL;
push(stack, 2);
push(stack, 5); //zadanie masz na telefonie
push(stack, -6);
cout << "gora stosu";
showtop(stack);
//cout << "po" << endl;
//del(head);
//show(head);
system("pause");
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}