![[백준 / BOJ] 10171번 고양이 (C++, Python) (부제 : 이스케이프 시퀀스)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FmLmRA%2FbtrLhgLpbZu%2FWewZ0Q5WaCOUokAbGPVkaK%2Fimg.jpg)
[백준 / BOJ] 10171번 고양이 (C++, Python) (부제 : 이스케이프 시퀀스)◎ 자료구조와 알고리즘/백준(BOJ) 문제풀이2022. 9. 4. 18:32
반응형
링크 : https://www.acmicpc.net/problem/10171
10171번: 고양이
아래 예제와 같이 고양이를 출력하시오.
www.acmicpc.net
문제

문제 풀이
역슬래시를 쓸 때에는 그 앞에 역슬래시를 하나 더 써야 한다는 사실을 알아야 하는 문제다. 이를 이스케이프 시퀀스라고 한다.

위 사진에 있는 문자들은 모두 특별한 기능을 하는 문자이기 때문에 출력하려면 앞에 \을 붙여야 한다.
C++의 경우 printf로 출력해보았다.
코드 전문
C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
void init() { | |
std::ios_base::sync_with_stdio(false); | |
std::cin.tie(nullptr); | |
std::cout.tie(nullptr); | |
} | |
int main() { | |
init(); | |
printf("\\ /\\\n"); | |
printf(" ) ( ')\n"); | |
printf("( / )\n"); | |
printf(" \\(__)|\n"); | |
return 0; | |
} |
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
input = sys.stdin.readline | |
if __name__ == "__main__": | |
print("\\ /\\") | |
print(" ) ( ')") | |
print("( / )") | |
print(" \\(__)|") |
소감
반응형
'◎ 자료구조와 알고리즘 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 / BOJ] 25083번 새싹 (C++, Python) (0) | 2022.09.04 |
---|---|
[백준 / BOJ] 10172번 개 (C++, Python) (0) | 2022.09.04 |
[백준 / BOJ] 2588번 곱셈 (C++, Python) (0) | 2022.09.04 |
[백준 / BOJ] 10430번 나머지 (C++, Python) (0) | 2022.09.04 |
[백준 / BOJ] 3003번 킹, 퀸, 룩, 비숍, 나이트, 폰 (C++, Python) (0) | 2022.09.03 |
@Reo :: 코드 아카이브
자기계발 블로그