#include #include #include #include "Item.h" #include "STACK.h" #define MAX 100000000 /*Priorities and dec values: + 1 //43 - 1 //45 * 2 //42 / 2 //47 ^ 3 //94 @ 4 //64 */ char string[MAX]; char a[MAX]; int main(int argc, char *argv[]){ //char *a = argv[1]; char c;// comment int i=0; //counter int j=0; //counter int N=0; char temp=0; while((c = getchar()) != EOF){ a[i]=c; i++; } N = strlen(a); STACKinit(N); //char string[MAX]; //Infix-to-postfix conversion for(i=0;i='0')&&(a[i] <='9')){ string[j]=a[i]; j++; string[j]=' '; j++; } // printf("the last temp is: %c\n",temp); //string[j]='\0'; } temp=STACKpop(a[i]); STACKpush(temp); printf("last temp is: %c\n",temp); string[j]=temp; j++; string[j]='\0'; printf("\n"); printf("the converted string is: %s\n",string); printf("the other string is: %s\n",a); /* //Postfix-expression evaluation N=strlen(string); STACKinit(N); for (i = 0; i < N; i++){ if (string[i] == '+'){ STACKpush(STACKpop()+STACKpop()); } if (string[i] == '*'){ STACKpush(STACKpop()*STACKpop()); } // if (string[i] == '^'){ STACKpush(STACKpop()*STACKpop()); } if (string[i] == '@'){ STACKpush(STACKpop()*STACKpop()); } if (string[i] == '-'){ STACKpush(STACKpop()+STACKpop()); } // if ((string[i] >= '0') && (string[i] <= '9')){ STACKpush(string[i]-'0'); } // while ((string[i] >= '0') && (string[i] <= '9')){ // STACKpush(10*STACKpop() + (string[i++]-'0')); // j++; // } } printf("%d \n", STACKpop()); */ return 0; }