&gizlimi&sizeID Yığınlar (Stack) Yığın - www.yazilimarsivi.blogcu.com - Blogcu



            

Yığınlar (Stack) Yığın

22/11/2008 ·

Stack

Örnek

// 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

0 yorum yazılmıştır

« Önceki :: Sonraki »