문제 : https://www.acmicpc.net/problem/18245
[알고리즘풀이]
i 번 째 문장에서는 i 칸씩 건너뛰어야되므로, 입력을 받으며 i 칸씩 건너뛰며 출력한 후 i 를 1씩 증가시킵니다.
#include<iostream>
#include<string>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int i = 2;
string A, B = "Was it a cat I saw?";
while (1) {
getline(cin, A);
if (A == B)
break;
for (int j = 0; j < A.length(); j += i)
cout << A[j];
cout << '\n';
i++;
}
}
'Problem Solving > BOJ' 카테고리의 다른 글
[BOJ] 15975 : 화살표 그리기 - travelbeeee (0) | 2020.01.21 |
---|---|
[BOJ] 2551 : 두 대표 자연수 - travelbeeee (0) | 2020.01.20 |
[BOJ] 1919 : 애너그램 만들기 - travelbeeee (0) | 2020.01.16 |
[BOJ] 4641 : Doubles - travelbeeee (0) | 2020.01.03 |
[BOJ] 1213 : 팰린드롬 만들기 - travelbeeee (0) | 2020.01.02 |