Advertisement
nadya_misheva

stek

Dec 5th, 2022
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. struct list{
  7.     list* prev;
  8.     char let;
  9. };
  10.  
  11. void push(list**L, char ch){
  12.     list* temp;
  13.     temp = new list;
  14.     temp->prev = (*L);
  15.     temp->let = ch;
  16.     (*L) = temp;
  17. }
  18.  
  19. char pop(list**L){
  20.     list * temp;
  21.     temp = (*L)->prev;
  22.     char ch = (*L)->let;
  23.     delete (*L);
  24.     (*L) = temp;
  25.     return ch;
  26. }
  27. int main()
  28. {
  29.     list * L;
  30.     L = NULL;
  31.     char s;
  32.     cin >> s;
  33.     push(&L, s);
  34.     cout << pop(&L);
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement