Notice
Recent Posts
Recent Comments
Link
250x250
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

피너클의 it공부방

백준 2902 KMP는 왜 KMP일까? (c++) : 피너클 본문

백준

백준 2902 KMP는 왜 KMP일까? (c++) : 피너클

피너클 2022. 10. 7. 18:42
728x90
반응형

https://www.acmicpc.net/problem/2902

 

2902번: KMP는 왜 KMP일까?

입력은 한 줄로 이루어져 있고, 최대 100글자의 영어 알파벳 대문자, 소문자, 그리고 하이픈 ('-', 아스키코드 45)로만 이루어져 있다. 첫 번째 글자는 항상 대문자이다. 그리고, 하이픈 뒤에는 반드

www.acmicpc.net

간단한 구현 문제다.

#include <iostream>
#include <string>

using namespace std;

string str;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> str;
	cout << str[0];
	for (int i = 1; i < str.length(); i++) {
		if (str[i - 1] == '-') cout << str[i];
	}
}

전체코드다.

728x90
반응형
Comments