Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define size 20
  4. int ex[size];
  5. int A[size];
  6. int top =-1;
  7.  
  8.  
  9. int main()
  10. {
  11. int i,x,n;
  12. scanf("%d",&n);
  13. for(i=0;i<n;i++)
  14. {
  15.  
  16. scanf("%d",ex[i]);
  17.  
  18. }
  19. BracketNum(x);
  20.  
  21. return 0;
  22. }
  23.  
  24. /*void print()
  25. {
  26. int i,l;
  27. l=strlen(ex);
  28. for(int i=0;i<l;i++)
  29. {
  30. printf("%d",l);
  31. }
  32. printf("\n");
  33.  
  34. }
  35. */
  36.  
  37. void BracketNum( int x)
  38. {
  39. int i,l;
  40. int count=1;
  41. l=strlen(ex);
  42.  
  43. for(i=0;i<l-1;i++)
  44. {
  45. if(ex[i] = '(' || '[' || '{')
  46. {
  47. printf("%d",count);
  48. push(count);
  49. count++;
  50.  
  51.  
  52.  
  53. }
  54. else if(ex[i] = ')' || ']' || '}')
  55. {
  56. printf("%d",count);
  57. pop();
  58.  
  59. }
  60.  
  61. }
  62. }
  63. void push(int x)
  64. {
  65. A[++top]=x;
  66. }
  67.  
  68. void pop()
  69. {
  70. return(A[top--]);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement