Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3.  
  4. char stiva[100];
  5. int vf = -1;
  6.  
  7. void push(char elem)
  8. {
  9. stiva[++vf] = elem;
  10. }
  11.  
  12. void pop(void)
  13. {
  14. return stiva[vf--];
  15. }
  16.  
  17. int main()
  18. {
  19. char input[100] = { "(a*(b-c)+d/(e+f*h)-i)" };
  20. char output[100];
  21. int i = 1;
  22. int k ;
  23. push(input[0]);
  24. while (vf != -1)
  25. {
  26. k = 0;
  27. if (input[i] >= 'a' && input[i] <= 'z')
  28. {
  29. output[k] = input[i];
  30. k++;
  31. }
  32. else
  33. {
  34. if (input[i] == '*' || input == '/') //prioritatea 1
  35. {
  36. push(input[i]);
  37. }
  38. }
  39. }
  40. printf("%s", output);
  41. _getch();
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement