[Programmers] #181948 - 특수문자 출력하기 [Java][C++][Python]
지정된 특수문자 조합을 그대로 출력하는 워밍업 문제.
[Programmers] #181948 - 특수문자 출력하기 [Java][C++][Python]
1. 아이디어
화면에 지정된 특수문자 조합 !@#$%^&*(\'"<>?:;을 그대로 출력하면 되는 문제다. 문자열 리터럴에 포함된 역슬래시(\)와 큰따옴표(")만 각 언어의 이스케이프 문법에 맞게 처리하면 나머지 특수문자는 그대로 출력할 수 있다.
2. 복잡도
| 접근 | 시간 | 공간 |
|---|---|---|
| 풀이 | $O(1)$ | $O(1)$ |
3. 코드
풀이 [Java][C++][Python]
1
2
3
4
5
public class Solution {
public static void main(String[] args) {
System.out.println("!@#$%^&*(\\'\"<>?:;");
}
}
1
2
3
4
5
6
7
8
9
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << "!@#$%^&*(\\'\"<>?:;";
}
1
print("!@#$%^&*(\\'\"<>?:;")
This post is licensed under CC BY 4.0 by the author.