2019 Java Chapter 18 (Week 14)

From: 2019-09-04 00:00:00 To: 2019-12-31 00:00:00 Now: 2024-11-23 18:31:34 Status: Public

D - 문자열 순열

Time Limit: 1s Memory Limit: 128MB

Submissions: 107 Solved: 86
Description

(String permutation) Write a recursive method to print all the permutations of a string. For example, for the string abc, the permuation is

 

입력된 문자열의 모든 순서를 출력하는 프로그램을 recursive method 로 작성하시오.

예를들어, abc 문자열이 입력되면

abc, acb, bac, bca, cab, cba

을 출력해야한다.

Input

Line 1 : 랜덤한 길이의 문자열

Output

Line 1 ~ 길이! : 각 문자열 순열

Sample Input
ABCD
Sample Output
ABCD
ABDC
ACBD
ACDB
ADBC
ADCB
BACD
BADC
BCAD
BCDA
BDAC
BDCA
CABD
CADB
CBAD
CBDA
CDAB
CDBA
DABC
DACB
DBAC
DBCA
DCAB
DCBA
Source

JAVA2015 PE18.25