Advertisement
Nikita051

Untitled

Feb 9th, 2023
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3. using namespace std;
  4.  
  5. int del(stack <int> s) {
  6.     while (!empty(s)) {
  7.         s.pop();
  8.     }
  9.     return 0;
  10. }
  11. int main() {
  12.     int counts;
  13.     cout << "Enter counts: ";
  14.     cin >> counts;
  15.     stack <int> s;
  16.     for (int i = 0; i < counts; i++) {
  17.         int num;
  18.         cout << "Enter num: ";
  19.         cin >> num;
  20.         s.push(num);
  21.     }
  22.     stack <int> temp;  
  23.     del(s);
  24.     while (!empty(s)) {
  25.         cout << s.top();
  26.         temp.push(s.top());
  27.         s.pop();
  28.     }
  29.     while (!empty(temp)) {
  30.         s.push(temp.top());
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement