Advertisement
Patey

Untitled

Apr 12th, 2021
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<stdlib.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. char st[100];
  6. int vf = -1;
  7.  
  8. int empty()
  9. {
  10.     if (vf == -1)
  11.         return 1;
  12.     else
  13.         return 0;
  14. }
  15.  
  16. void push(char a)
  17. {
  18.     vf++;
  19.     st[vf] = a;
  20. }
  21.  
  22. void pop()
  23. {
  24.     vf--;
  25. }
  26.  
  27. int main()
  28. {
  29.     char a[1];
  30.     int i;
  31.     while (1)
  32.     {
  33.         scanf("%c", a);
  34.         if (strcmp(a,"S")==1)
  35.             break;
  36.         if (empty() == 1)
  37.             push(a[1]);
  38.         else if (a != st[vf])
  39.             pop();
  40.         else
  41.             push(a[1]);
  42.     }
  43.  
  44.     for (i = 0; i <= vf; i++)
  45.     {
  46.         printf("%c\n", st[i]);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement