90分心态逐渐崩溃
查看原帖
90分心态逐渐崩溃
1027709
Licober楼主2023/8/3 11:07
#include <iostream>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <string.h>
#include <string>
#include <numeric>
#include <climits>
#include <regex>

using namespace std;

void func(int p1, int p2, int p3, string &str)
{
    if (isalpha(str[0]))
    {
        if (p1 == 2)
        {
            for (auto &s : str)
            {
                s = toupper(s);
            }
        }
    }
    if (p1 == 3)
    {
        string tmp(str.size() * p2, '*');
        str = tmp;
        return;
    }

    string tmp = "";
    for (int i = 0; i < str.size(); i++)
    {
        string a(p2, str[i]);
        tmp += a;
    }
    str = tmp;

    if (p3 == 2)
        reverse(str.begin(), str.end());
}

int main()
{
    int p1, p2, p3;
    cin >> p1 >> p2 >> p3;
    string source;
    cin >> source;

    vector<string> mout;
    int i = 0;
    while (source[i] == '-')
        i++;

    int index = -i;
    for (; i < source.size(); i++)
    {
        string tmp = "";
        if (source[i] == '-' && (i - 1 >= 0) && (i + 1 < source.size()))
        {
            if (source[i - 1] == source[i + 1] - 1)
            {
                source[i] = '*';
            } // (source[i - 1] > source[i + 1]) || (isdigit(source[i - 1]) && isalpha(source[i + 1])) || (isdigit(source[i + 1]) && isalpha(source[i - 1]))
            else if ((isdigit(source[i - 1]) && isdigit(source[i + 1])) || (isalpha(source[i - 1]) && isalpha(source[i + 1])))
            {
                if (source[i - 1] < source[i + 1])
                {
                    int k = source[i + 1] - source[i - 1];
                    for (int j = 1; j < k; j++)
                        tmp.push_back(source[i - 1] + j);
                    func(p1, p2, p3, tmp);
                }
                mout.push_back(tmp);
            }
            else
            {
                mout.push_back(tmp);
            }
        }
    }

    // cout << mout.size() << endl;
    // for (auto &s : mout)
    //     cout << s << endl;

    for (auto &s : source)
    {
        if (s == '-')
        {
            if (mout[index] != "")
                cout << mout[index];
            else
                cout << s;

            index++;
        }
        else if (s != '*')
            cout << s;
    }

    return 0;
}

(int 7) 2 8 2 --09-8-w-er-7h-08w-e7-hc-r890-q7w-eh-rc98-07-q8-ewr-8h-c-8-294-5-dsf--k-h-2-48-3k-h-sd-fq-a-

答案输出 --09-8-w-er-7h-08w-e7-hcQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIHHHHHHHHGGGGGGGGFFFFFFFFEEEEEEEEDDDDDDDDr890-q7w-ehQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIrc98-07-q8-ewr-8h-c-8-2945-dsf--k-h-23333333348-3k-hRRRRRRRRQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIsdEEEEEEEEfq-a-

本地测试输出 --09-8-w-er-7h-08w-e7-hcQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIHHHHHHHHGGGGGGGGFFFFFFFFEEEEEEEEDDDDDDDDr890-q7w-ehQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIrc98-07-q8-ewr-8h-c-8-2945-dsf--k-h-23333333348-3k-hRRRRRRRRQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIsdEEEEEEEEfq-a-

2023/8/3 11:07
加载中...