我正在使用以下技术来查找数学字符串中的运算符数量。
for (int index = 0; index < [self.evaluateString length]; index++) {
unichar chars = [self.evaluateString characterAtIndex:index];
if (chars == '+' || chars == '-' || chars == '*' || chars == '/' ||chars == '^') {
self.operatorCount++;
}
}
我的教练说这种方法不是很好。我想知道有没有更好/更优雅的方法来做到这一点。谢谢。