1066

// PATn.cpp : 定義控制臺應用程序的入口點。
//

#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>

using namespace std;

string format(string s)
{
    auto tmp = 3 - s.size();
    if (tmp > 0)
    {
        s = string(tmp, '0') + s;
    }
    return s;
}

string change_color(unsigned s, unsigned a, unsigned b, string tc)
{
    if (a <= s && s <= b)
    {
        return tc;
    }
    else
    {
        return format(to_string(s));
    }


}


int main()
{
    unsigned m, n;
    unsigned a, b;
    string to_color;
    cin >> m >> n >> a >> b >> to_color;
    to_color = format(to_color);

    vector<vector<string>> format_color(m,vector<string>(n,""));
    for (unsigned i = 0; i < m; ++i)
    {
        for (unsigned j = 0; j < n; ++j)
        {
            unsigned tmp;
            cin >> tmp;

            auto tmp_color = change_color(tmp, a, b, to_color);
            format_color[i][j] = tmp_color;
        }
    }

    for (size_t i = 0; i < format_color.size(); ++i)
    {
        for (size_t j = 0; j < format_color[i].size(); ++j)
        {
            cout << format_color[i][j];
            if (j != (format_color[i].size() - 1))
                cout << " ";
        }
        if (i != (format_color.size() - 1))
        {
            cout << endl;
        }
    }

    system("pause");
    return 0;
}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容