1066

作者: 峡迩 | 来源:发表于2017-09-05 14:22 被阅读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;
    }
    
    

    相关文章

      网友评论

          本文标题:1066

          本文链接:https://www.haomeiwen.com/subject/zxbujxtx.html