본문 바로가기

Coding/백준 온라인 저지 (Baekjoon Online Judge)

백준 온라인 저지(Baekjoon Online Judge) - 2789 : 유학 금지

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

 

2789번: 유학 금지

아주 멀리 떨어져 있는 작은 나라가 있다. 이 나라에서 가장 공부를 잘하는 학생들은 모두 다른 나라로 유학을 간다. 정부는 최고의 학생들이 자꾸 유학을 가는 이유를 찾으려고 했다. 하지만,

www.acmicpc.net

 

#include <iostream>
#include <string>
using namespace std;

int main() {
	string word;
	getline(cin, word);

    string cambridge = "CAMBRIDGE";
    string result = ""; // 검열된 결과 단어

    for (int i = 0; i < word.length(); i++) {
        bool is_in_cambridge = false;
        for (int j = 0; j < cambridge.length(); j++) {
            if (word[i] == cambridge[j]) {
                is_in_cambridge = true;
                break;
            }
        }
        if (!is_in_cambridge) {
            result += word[i];
        }
    }

    cout << result << endl; // 결과 출력

    return 0;

}