L1-054 福到了 分數 15

Frodnx發表於2024-08-06

輸入->判斷正反是否一致->輸出

// 11'43"
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    int n;
    cin >> ch >> n;
    vector<string> v;
    string emp;
    getline(cin,emp);
    for(int i = 1; i <= n; ++ i)
    {
        string s;
        getline(cin,s);
        v.push_back(s);
    }

    bool flag = false;
    for(int i = 0, j = v.size() - 1; i < j; ++ i, -- j)
        if(v[i] != v[j]) flag = true;
        
    if(flag == false)
    {
        cout << "bu yong dao le\n";
        for(int i = 0; i < v.size(); ++ i)
        {
            for(int j = 0; j < v[i].size(); ++ j)
                if(v[i][j] != ' ') cout << ch;
                else cout << ' ';
            cout << endl;
        }
    }
    else
    {
        reverse(v.begin(),v.end());
        for(int i = 0; i < v.size(); ++ i)
        {
            for(int j = v[i].size() - 1; j >= 0; -- j)
                if(v[i][j] != ' ') cout << ch;
                else cout << ' ';
            cout << endl;
        }
    }
    return 0;
}

相關文章