Standard Template Library Stack на C++


#include "stdafx.h"
#include <stack>
#include <iostream>
#include <string>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL,"Rus");
stack <char> box;
box.push('q');
box.push('j');
box.push('r');
box.push('f');
box.push('y');
cout<<"Количество элементов "<<box.size()<<endl;
while(!box.empty())
{
cout<<box.top()<<" Элемент удален "<<endl;
box.pop();
}
// конструктор
box.push('t');
stack <char> new_box(box);
cout<<new_box.top()<<endl;
system("pause");
return 0;
}

Результат работы программы Stack LIFO stack (last-in first-out):

STL Stack на C++

440

Leave a Reply

Ваш адрес email не будет опубликован.