Post

[Programmers] 181948번 - 특수문자 출력하기 [Java][C++]

[Programmers] 181948번 - 특수문자 출력하기 [Java][C++]

문제 링크


1. 아이디어

요구된 특수문자 문자열을 언어별 이스케이프 규칙에 맞춰 그대로 출력해주면 된다.


2. 복잡도

시간복잡도공간복잡도
$O(1)$$O(1)$

3. 코드

풀이 [Java][C++]

Java의 경우 ", \를 이스케이프 처리해주면 된다.

1
2
3
4
5
public class Solution {
    public static void main(String[] args) {
        System.out.println("!@#$%^&*(\\'\"<>?:;");
    }
}

C++의 경우 ", \를 이스케이프 처리해주면 된다.

1
2
3
4
5
6
7
#include <iostream>

using namespace std;

int main(void) {
    cout << "!@#$%^&*(\\'\"<>?:;";
}

This post is licensed under CC BY 4.0 by the author.