Uefa Maçları Canlı İzle
RSS
 

Veri yapıları ve algoritmalr Yığınlar (Stack) Yığın

21 Eki

Veri yapıları ve algoritmalr Yığınlar (Stack) Yığın örnek uygulama proje

// stack::push/pop

#include

#include

using namespace std;

int main ()

{

stack<int> mystack;

for (int i=0; i<5; ++i) mystack.push(i);

cout << ”Popping out elements…”;

while (!mystack.empty())

{

cout << ” “ << mystack.top();

mystack.pop();

}

cout << endl;

return 0;

}

çıktı:

Popping out elements… 4 3 2 1 0

Örnek 2

// stack::push/pop

#include

#include

using namespace std;

int main ()

{

stack<int> mystack;

for (int i=0; i<5; ++i) mystack.push(i);

cout << ”Popping out elements…”;

while (!mystack.empty())

{

cout << ” “ << mystack.top();

mystack.pop();

}

cout << endl;

return 0;

}

Output: Popping out elements… 4 3 2 1 0
 
1 Comment

Posted in C++

 

Leave a Reply

 

 
  1. yuhubaa

    23 Ekim 2009 at 15:10

    Kullananların ve deneyenlerin yorum ve önerilerini dinlemek isterim :)