4.4
Copied!
#include <iostream>
using namespace std;
#include "stack.h"
int main()
{
Stack<char> stackSymbol(5);
int ct = 0;
char ch;
while (ct < 5) {
cin >> ch;
stackSymbol.push(ch); // element qoʻshish
}
cout << endl;
stackSymbol.printStack(); // ekranga chiqarish
cout << "\n\n Element oʻchirish\n";
stackSymbol.pop();
stackSymbol.printStack(); // ekranga chiqarish
Stack<char> newStack(stackSymbol);
cout << "\n\nNusxalash konstruktori!\n";
newStack.printStack();
cout << "2 tartibdagi element: " << newStack.Peek(2) << endl;
system("pause");
return 0;
}
Run on cpp.sh
Copied!