백준 18245번: 이상한 나라의 암호

danbibibi·2022년 5월 17일
0

문제

문제 바로가기> 백준 18245번: 이상한 나라의 암호

풀이

간단한 구현 문제이다! 해당 조건에 맞추어 구현해주었다.

#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    for(int i=1; true; i++){
        string str; getline(cin, str);
        if(str == "Was it a cat I saw?") return 0;
        int idx=0;
        while (idx<str.length()){
            cout << str[idx];
            idx+=(i+1);
        } cout << "\n";
    }
}
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글