Programmer ::fizmhd(MEA) www.mdown.co.cc*/
#include
void check(char);
void push(char);
struct node
{
char info;
struct node *r,*l;
}temp,*operator[10],*operand[10];
typedef struct node N;
int p,top1=0,top2=0;
main()
{
char exp[20];
printf("\nENter the expression :: ");
gets(exp);
for(i=0;exp[i]!='\0';i++)
{
check(exp[i]);
printf("\nThe priority value of %c is %d \n",exp[i],p);
push(exp[i]);
}
}
void check(char x)
{
p=-1;
switch(x)
{
case '*' :
p=1;
break;
case '/' :
p=1;
break;
case '+' :
p=2;
break;
case '-' :
p=2;
break;
default :
p=3;
break;
}
}
void push(char x)
{
temp=(N*)malloc(sizeof(N));
temp->info=x;
temp->l=NULL;
temp->r=NULL;
switch(p)
{
case 1 :
break;
case 2 :
break;
case 3 :
operand[top1++]=temp;
break;
}
}
No comments:
Post a Comment