//基础的C语言栈解法,要注意数组角标。本题中使用的结构体其实可以直接用一个数组来代替。QvQ
int evalRPN(char** tokens, int tokensLen ) {
// write code here
int result=0;
struct{
int integer[10000];
int topIdx;
}str={{0},0};
for(int i=0,j=0;i<tokensLen;i++){
if(strcmp(tokens[i],"+")==0){
result=str.integer[str.topIdx-1]+str.integer[str.topIdx-2];
str.topIdx--;
str.integer[str.topIdx-1]=result;
}
else if(strcmp(tokens[i],"-")==0){
result=str.integer[str.topIdx-2]-str.integer[str.topIdx-1];
str.topIdx--;
str.integer[str.topIdx-1]=result;
}
else if(strcmp(tokens[i],"*")==0){
result=str.integer[str.topIdx-2]*str.integer[str.topIdx-1];
str.topIdx--;
str.integer[str.topIdx-1]=result;
}
else if(strcmp(tokens[i],"/")==0){
result=str.integer[str.topIdx-2]/str.integer[str.topIdx-1];
str.topIdx--;
str.integer[str.topIdx-1]=result;
}
else{
str.integer[str.topIdx]=atoi(tokens[i]);
str.topIdx++;
}
}
return str.integer[0];
}