알고리즘

[알고리즘] 백준 11586 - 지영 공주님의 마법 거울 (C++)

blueberrysoda 2024. 12. 25. 23:56

[문제 링크] : https://www.acmicpc.net/problem/11586

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, M;
    cin >> N;
    vector<string> V;
    while(N--){
        string S;
        cin >> S;
        V.push_back(S);
    }

    cin >> M;
    if(M == 1){
        for(int i=0; i<V.size(); i++){
            cout << V[i] << "\n";
        }
    }
    else if(M == 2){
        for(int i=0; i<V.size(); i++){
            reverse(V[i].begin(), V[i].end());
            cout << V[i] << "\n";
        }
    }
    else{
        reverse(V.begin(), V.end());
        for(auto i=0; i<V.size(); i++){
            cout << V[i] << "\n";
        }
    }
    return 0;
}