728x90
CAMBRIDGE를 char배열에 넣어주고
입력받은 string의 문자 하나하나를
find함수를 통해서 char배열에 있는지 확인합니다.
없을 경우 문자를 그대로 출력하고, 있으면 출력하지 않습니다.
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
char *p;
string s;
char c[9] = { 'C', 'A', 'M', 'B', 'R', 'I', 'D', 'G', 'E' };
cin >> s;
for (int i = 0; i < s.length(); ++i) {
p = find(c, c + 9, s[i]);
if (p == c + 9) {
cout << s[i];
}
}
cout << endl;
return 0;
}
'알고리즘' 카테고리의 다른 글
[C++] 백준 9625번 BABBA (0) | 2019.09.24 |
---|---|
[C++] 백준 3040번 백설 공주와 일곱 난쟁이 (0) | 2019.09.24 |
[C++] 백준 2822번 점수 계산 (0) | 2019.09.24 |
[C++] 백준 4641번 Doubles (0) | 2019.09.23 |
[C++] 백준 6321번 IBM 빼기 1 (0) | 2019.09.23 |