[백준/C++] 11365번: !밀비 급일
[백준/C++] 11365번: !밀비 급일
문제 & 링크
https://www.acmicpc.net/problem/11365
풀이
string과 getline() 함수를 사용하여 줄 단위로 암호를 입력 받는다.
algorithm 헤더 파일의 reverse()함수를 사용하여 암호를 뒤집어서 해독한다.
1 - 2의 과정을 반복문을 이용하여 실행하고, if문으로 “END”가 나올 때 까지 반복한다.
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string egassem;
while(1) {
getline(cin, egassem);
if (egassem == "END") break;
reverse(egassem.begin(), egassem.end());
cout << egassem << endl;
}
return 0;
}
This post is licensed under CC BY 4.0 by the author.
