请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册
查看: 1673|回复: 0

C#括号配对

[复制链接]

1278

主题

1504

帖子

90

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22549
发表于 2022-9-12 17:00:50 | 显示全部楼层 |阅读模式
C#括号配对
  1. public int findClosingParen(char[] text, int openPos) {
  2.     int closePos = openPos;
  3.     int counter = 1;
  4.     while (counter > 0) {
  5.         char c = text[++closePos];
  6.         if (c == '(') {
  7.             counter++;
  8.         }
  9.         else if (c == ')') {
  10.             counter--;
  11.         }
  12.     }
  13.     return closePos;
  14. }
复制代码

参考:
【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

算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-3-28 23:09 , Processed in 0.197412 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表