Untitled
unknown
plain_text
a year ago
627 B
2
Indexable
Never
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<ctype.h> #define MAX 50 int stack[MAX] char post[MAX] int top=-1; void pushstack(int tmp); void calculator(char c); void main(){ int i ; clrscr(); printf("insert a postfix notation :"); gets(post); for(i=0;i<strlen(post);i++){ if(post[i]>='0'&& post[i]<='0'){ pushstack(); } if(post[i]=='+'| post[i]=='-' |post[i]=='*' |post[i]=='/'|post[i]=='^' ){ calculator(post[i]); } printf("\n\n result:"%d",stack[top]); getch(); } } void pushstack(int tmp){ top++; stack[top]=(int)(post[tmp]-48); } void calculator