#include <iostream> #include <string> using namespace std; string helper(string& s, int& index) {     string res, tmp;     int x = 0;     while(index < s.size()) {         if(s[index] == '('){ #遇到左括号递归开始             index++;             res += helper(s,index);         }else if(s[index] == ')') { #遇到右括号计算后面的数字,算完之后return             index++;             while(s[index] >= '0' && s[index] <= '9') {                 x = x*10+(s[index++]-'0');             }             tmp = res;             while(--x)                 res += tmp;             return res;         }else if(s[index] >= '0' && s[index] <= '9') {#直接遇到数字说明是单个字母的重复             x = 0;             while(s[index] >= '0' && s[index] <= '9') {                 x = x*10+(s[index++]-'0');             }             while(--x)                 res += res.back();         }         else{#其它字母直接加             res += s[index++];         }     }     return res; } int main() {     int n = 0,index = 0;     string s;     getline(cin,s);     n = stoi(s);     for(int i = 0; i < n; i++) {         getline(cin,s);         index = 0;         string res = helper(s,index);         cout << res <<endl;     }     return 0; } 来个C++版的
点赞 评论

相关推荐

notbeentak...:就抓,嗯抓,开不开匿名都要抓,一点坏事不让说,就对公司顶礼膜拜佩服的五体投地就对了
点赞 评论 收藏
分享
10-15 10:23
门头沟学院 Java
牛可乐的头像真牛:赶紧举报,这公司绝对是诈骗的,等你签约后工作一两个月后根据合同漏洞把你开除,并且要求你赔偿3w培训费,996是为了提前筛选心甘情愿签下合同容易受骗的群体,纯粹面向校招生精心设计的骗局
你见过哪些工贼行为
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务