Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- char stiva[100];
- int vf = -1;
- void push(char elem)
- {
- stiva[++vf] = elem;
- }
- void pop(void)
- {
- return stiva[vf--];
- }
- int main()
- {
- char input[100] = { "(a*(b-c)+d/(e+f*h)-i)" };
- char output[100];
- int i = 1;
- int k ;
- push(input[0]);
- while (vf != -1)
- {
- k = 0;
- if (input[i] >= 'a' && input[i] <= 'z')
- {
- output[k] = input[i];
- k++;
- }
- else
- {
- if (input[i] == '*' || input == '/') //prioritatea 1
- {
- push(input[i]);
- }
- }
- }
- printf("%s", output);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement