void Suffix()
{
char input[STACKMAX];
char str[STACKMAX];
char result[STACKMAX];
int i = 0, j, sum;
int top_str = 0, top_res;
char ch;
getchar();
printf("请输入中缀表达式,以'#'结束:");
do
{
i++;
scanf("%c", &input[i]);
} while ('#' != input[i] && i != STACKMAX);
sum = i;
top_res = 1;
i = 1;
ch = input[i];
while ('#' != ch)
{
switch (ch)
{
case '(':
top_str++;
str[top_str] = ch;
break;
case ')':
while ('(' != str[top_str])
{
result[top_res++] = str[top_str--];
result[top_res++] = ' ';
}
top_str--;
break;
case'+':
case'-':
while (0 != top_str && '(' != str[top_str])
{
result[top_res++] = str[top_str--];
result[top_res++] = ' ';
}
str[++top_str] = ch;
break;
case'*':
case'/':
while ('*' == str[top_str] || '/' == str[top_str])
while (0 != top_str && '(' != str[top_str])
{
result[top_res++] = str[top_str--];
result[top_res++] = ' ';
}
str[++top_str] = ch;
break;
case' ':
break;
default:
while (ch >= '0' && ch <= 'z')
{
result[top_res++] = ch;
i++;
ch = input[i];
}
i--;
result[top_res++] = ' ';
}
i++;
ch = input[i];
}
while (0 != top_str)
{
result[top_res++] = str[top_str--];
if (top_str != 0)
result[top_res++] = ' ';
}
printf("输入的中缀表达式为:");
for (j = 1; j < sum; j++)
printf("%c", input[j]);
printf("转化为后缀表达式为:");
for (j = 1; j < top_res; j++)
printf("%c", result[j]);
printf("\n");
}
这串代码里面哪里有问题
使这个后缀表达式错误了
正确的形式是3 4 25 6 15 + - / 8 * +