Ai giúp mình tìm lỗi của code "chuyển biểu thức trung tố sang hậu tố " này với ạ ! mình cảm ơn nhiều@@
#include<stdio.h>
#include<string.h>
void nhap( char chuoi[100])
{
printf("nhap : ");
gets(chuoi);
}
struct nut
{
char giatri;
nut*tiep;
};
typedef nut node;
node *dau;
void KhoiTao(node*&dau)
{
dau=NULL;
}
void mocdau(node*&dau,char x)
{
node*p;
p=new node;
p->giatri = x;
p->tiep = NULL;
if(dau== NULL) dau=p;
else
{
p->tiep=dau;
dau=p;
}
}
int UuTien(char x)
{
if ((x == '(')||(x == ')')) return 1;
else if ((x == '+')||(x == '-')) return 2;
else return 3;
}
void ChuyenDoi(node*dau,char a[100])
{
char HauTo[100];int j=0;
for(int i=0;i<strlen(a);i++)
{
if(a[i]>47&&a[i]<58) HauTo[j++]=a[i];
else
{
if(a[i]=='(') mocdau(dau,a[i]);
else
{
if(a[i]==')')
{ while(dau->giatri !='(')
{
HauTo[j++]=dau->giatri;
node*p=dau;
dau=dau->tiep;
delete p;
}
node*p=dau;
dau=dau->tiep;
delete p;
}
else
{
while(UuTien(dau->giatri)<=UuTien(a[i])&&dau!=NULL )
{
HauTo[j++]=dau->giatri;
node*p=dau;
dau=dau->tiep;
delete p;
}
mocdau(dau,a[i]);
}
}
}
}
while(dau!=NULL)
{
HauTo[j++]=dau->giatri;
node*p=dau;
dau=dau->tiep;
delete p;
}
for(int i=0;i<j;i++)
printf("%c",HauTo[i]);
}
int main()
{
char chuoi[] = "3*5+3*6";
ChuyenDoi(dau,chuoi);
}