Halcom 发表于 2022-9-12 17:00:50

C#括号配对

C#括号配对
public int findClosingParen(char[] text, int openPos) {
    int closePos = openPos;
    int counter = 1;
    while (counter > 0) {
      char c = text[++closePos];
      if (c == '(') {
            counter++;
      }
      else if (c == ')') {
            counter--;
      }
    }
    return closePos;
}
参考:
【1】https://blog.csdn.net/lanazyit/article/details/109443666
【2】https://blog.csdn.net/qq_45063234/article/details/106761013
【3】https://www.codingdict.com/questions/94598

页: [1]
查看完整版本: C#括号配对