#include<stdio.h>
#include<string.h>
#include<ctype.h>
char s[200];
char stack[200]={'('};
int top=0;
void pp(int i);
int main(){
gets(s);
int k=strlen(s);
for(int i=0;i<=k;i++){
if(isdigit(s[i]))printf("%d",s[i]-'0');
else pp(i);
}
}
void pp(int i){
if(s[i]=='+'||s[i]=='-'){
if(stack[top]!='*'&&stack[top]!='/'){
stack[++top]=s[i];
}else{
int n=top;
while(stack[n]!='('){
printf("%c",stack[n--]);
}
stack[++top]='(';
stack[++top]=s[i];
}
}else if(s[i]==')'){
int n=top;
while(stack[n]!='('){
printf("%c",stack[n--]);
}
stack[++top]='(';
}else if(s[i]=='\0'){
int n=top;
while(stack[n]!='('){
printf("%c",stack[n--]);
}
}else stack[++top]=s[i];
}
标签:200,中缀,后缀,char,int,include
From: https://www.cnblogs.com/sunyang13763857269/p/16965274.html