• 【PAT】B1052 卖个萌(20 分)


    实在不想写这个题,好费劲,头疼,这是粘的柳婼的代码 ,等我有空再自己用c写吧

    
    #include <iostream>
    #include <vector>
    using namespace std;
    int main() {
        vector<vector<string> > v;
        for(int i = 0; i < 3; i++) {
            string s;
            getline(cin, s);
            vector<string> row;
            int j = 0, k = 0;
            while(j < s.length()) {
                if(s[j] == '[') {
                    while(k++ < s.length()) {
                        if(s[k] == ']') {
                            row.push_back(s.substr(j+1, k-j-1));
                            break;
                        }
                    }
                }
                j++;
            }
            v.push_back(row);
        }
        int n;
        cin >> n;
        for(int i = 0; i < n; i++) {
            int a, b, c, d, e;
            cin >> a >> b >> c >> d >> e;
            if(a > v[0].size() || b > v[1].size() || c > v[2].size() || d > v[1].size() || e > v[0].size() || a < 1 || b < 1 || c < 1 || d < 1 || e < 1) {
                cout << "Are you kidding me? @\/@" << endl;
                continue;
            }
            cout << v[0][a-1] << "(" << v[1][b-1] << v[2][c-1] << v[1][d-1] << ")" << v[0][e-1] << endl;
        }
        return 0;
    }
    
  • 相关阅读:
    IO流
    异常,File,递归,IO流
    Collection接口 map
    使用canvas画出的时钟
    js对象2
    js对象
    js 猜数游戏、斗地主发牌、伪数字
    js函数2
    js函数
    js矩形,数组,杨辉三角
  • 原文地址:https://www.cnblogs.com/hebust/p/9496803.html
Copyright © 2020-2023  润新知