gcccccccc level
获赞
21
粉丝
1
关注
2
看过 TA
3
南京航空航天大学
2020
Java
IP属地:上海
暂未填写个人简介
私信
关注
2019-08-03 21:03
已编辑
南京航空航天大学 Java
import java.util.Scanner; public class Main {     public static void main(String[] args) {         Scanner in = new Scanner(System.in);         int num = Integer.parseInt(in.nextLine());         String[] strArr = new String[num];         for (int i = 0; i < num; i++) {             strArr[i] = i...
大毛子:#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++版的
投递猿辅导等公司9个岗位 >
0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务