n对括号可以有多少种匹配方式分治+代码C
时间: 2024-01-15 09:03:18 浏览: 72
```
#include <iostream>
using namespace std;
int count(int n) {
if (n == 0) return 1;
int ans = 0;
for (int i = 0; i < n; i++) {
ans += count(i) * count(n - i - 1);
}
return ans;
}
int main() {
int n;
cin >> n;
cout << count(n) << endl;
return 0;
}
```
阅读全文