求大佬哪里错了

P1241 括号序列

Losanli @ 2022-06-30 20:20:33

只过了4个测试点

/*

*/
#include<bits/stdc++.h>
#define N 10010
#define INI 999999999
using namespace std;
int main()
{
char n[100100];
int a=0;
int b=0;
cin>>n;
for(int i=0;i<=100100;i++)
{
    if(n[i]=='[')
    {
        a++;//计数 
    }
    if(n[i]=='(')
    {
        b++;
    }
    if(n[i]==' ')
    {
        break;
    }
}
for(int i=1;i<=b;i++)
{
    cout<<"()";
}
for(int i=1;i<=a;i++)
{
    cout<<"[]";
}

return 0;
}

by ztghzk @ 2022-06-30 20:52:40

末尾循环有问题


by Losanli @ 2022-07-01 10:01:23

谢谢大佬


by Losanli @ 2022-07-01 10:03:21

哪里错了


|