我正在尝试编写这样的递归函数
int nestedExpression(){
char expCh;
scanf(" %c", &expCh);
if(expCh == '\n'){
return 0;
}
nestedExpression();
\\deal with the return
return 0;
现在我的输入是 (1 + 1) 并且当它到达角色时 ) 它正在按原样对待它 ' '.
想想这一点
scanf(" %c", &expCh);
if(expCh == '\n'){
return 0;
}
当 expCh 不是 ' ',以后你总是
return 0;
我想这就是为什么你认为每个角色都被视为“ '.
此外,您对递归调用的结果不做任何事情
nestedExpression();
您需要将其分配给变量。