#include <string>
#include <cctype> // islower
#include <iostream>
int main()
{
std::string id[2] = {"joonas", "backjoon"};
char input[50];
std::cin >> input;
std::string str(input);
std::string exist = "??!";
for (int i = 0; i < sizeof(id); i++)
{
if (std::islower(input[i]) && input == id[i])
{
std::cout << str + exist << std::endl;
break;
}
}
return 0;
}
- 입력이 모두 소문자로 이루어져 있는지 확인하기 위해 islower()를 이용했다. cctype 라이브러리에 포함되어 있다.
- std::string은 덧셈으로 합칠 수 있고 std::cout을 이용해 출력할 수 있다.
printf()는 std::string를 덧셈으로 이용할 수 없다.
'C, C++ > 공부정리' 카테고리의 다른 글
[백준 그리디 10807] 개수 세기 - 배열 (배열의 크기는 변수로 지정할 수 없다. 배열의 동적할당) (0) | 2023.10.02 |
---|---|
[백준 그리디 11382] 꼬마 정민 - 자료형 long long (0) | 2023.08.09 |
[백준 그리디 1008] A/B - 자료형 주의! (0) | 2023.08.07 |
goto문 (0) | 2023.07.23 |
switch case문 (0) | 2023.07.23 |