Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

stack: Exemple d’ajout et de suppression


{filelink=15102}

 
#include <iostream>
#include <stack>
using namespace std;
 
int main()
{
 
   stack< int > intStack;
 
   //Ajouter des élément à la tête de 'stack'
   for ( int i = 0; i <= 9; i++ )
   {
      intStack.push( i );
      cout << "Val: "<< intStack.top() << "n";
   }
 
  cout<<"Affichage LIFOn";
   while ( !intStack.empty() )
   {
      cout << "Val: "<<intStack.top() << "n";
      intStack.pop();
   }
 
   return 0;
}

No comments yet.

Leave a Comment