标签:parent pre ima com amp color code mic 计算
1.括号匹配
int isMatched(char left,char right){ if(left == ‘(‘&& right == ‘)‘){ return 1; }else if(left == ‘[‘&&right ==‘]‘){ return 1; }else if(left == ‘{‘&&right ==‘}‘){ return 1; }else{ return 0; } }
int isParenthesesBalanced(char exp[]){ char s[MaxSize];int top=-1; for(int i=0;exp[i]!=‘\0‘;i++){ if(exp[i] ==‘(‘ ||exp[i] ==‘{‘||exp[i]==‘[‘){ s[++top]=exp[i]; } if(exp[i] == ‘)‘||exp[i] == ‘}‘||exp[i]==‘]‘){ if(top ==-1){ return 0; } char left=s[top--]; if(isMatched(left,exp[i]) == 0){ return 0; } } } if(top>-1){ return 0; } return 1; }
2.计算问题
int calF(int m){ int cum=1; int s[MaxSize],top=-1; while(m!=0){ s[++top]=m; m/=3; } while(top!=-1){ cum*=s[top--]; } return cum; }
标签:parent pre ima com amp color code mic 计算
原文地址:https://www.cnblogs.com/jcahsy/p/13191061.html