1066

2017-09-05  本文已影响0人  峡迩
// 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;
}

上一篇下一篇

猜你喜欢

热点阅读