括号匹配(二)nyoj

#include  
#include  
  
char _stack[205];  
int head = -1;  
int rear;  
void pop()  
{  
    head--;  
}  
  
void push(char ch)  
{  
    _stack[++head] = ch;  
}  
  
char top()  
{  
    return _stack[head];  
}  
  
int main()  
{  
    int n;  
    int i;  
    int j;  
    int cnt;  
    int run;  
    char str[105];  
    scanf("%d",&n);  
    while(n--)  
    {  
        cnt = 0;  
        head = -1;  
        scanf("%s",str);  
        for(i=0; i

RT记录一下 标程式DP也帖一下以后看

#include  
#include  
#include  
  
  
using namespace std;  
const int maxn=110;  
char tab[maxn];  
int f[maxn][maxn];  
  
  
int fun(int i,int j)  
{  
    if(i>j)return 0;  
    if(f[i][j]>=0)return f[i][j];  
    if(i==j)return f[i][j]=1;  
    int va=maxn;  
    if((tab[i]=='('&&tab[j]==')') || (tab[i]=='['&&tab[j]==']'))  
        va=fun(i+1,j-1);  
    for(int mid=i;mid

你可能感兴趣的:(括号匹配(二)nyoj)