大佬帮帮我
查看原帖
大佬帮帮我
819273
LIUYC_C楼主2023/3/9 09:29

四十分模拟哪错了??

#include <bits/stdc++.h>
using namespace std;
const int N=110;
typedef long long LL;
string s,q;

int main(){
    getline(cin,s);
    int l=s.size();
    for(int i=0;i<l;i++){
        if(s[i]>='A'&&s[i]<='Z'){
            q+=s[i];  
        }
        else if(s[i]=='['){
            int temp=1;
            string ls;
            while(s[i]!=']'){
                i++;
                if(isdigit(s[i])){
                    temp*=s[i]-'0';
                }
          else if(s[i]>='A'&&s[i]<='Z'){
                    ls+=s[i]; 
                }
            }
            for(int i=1;i<=temp;i++){
                q+=ls;
            }
        }
    }
    cout<<q;
    return 0;
}
2023/3/9 09:29
加载中...