import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Baby_Gin_Game {
static int[] arr;
static int len = 0;
static int[] visited;
static int[] map;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
arr = new int[s.length()];
for (int i = 0; i < s.length(); i++) {
arr[i] = Integer.parseInt(s.substring(i, i + 1));
}
len = arr.length;
visited = new int[len];
map = new int[len];
findPermu(0);
}
private static int findPermu(int depth) {
if (depth == len) {
for (int n : map) {
System.out.print(n + " ");
}
System.out.println();
return 1;
}
for (int i = 0; i < len; i++) {
if (visited[i] == 1) {
continue;
}
map[depth] = arr[i];
visited[i] = 1;
findPermu(depth + 1);
}
return 0;
}
}
- visited[i] = 0 이라는 코드를 놓치면 안된다!!!
map[depth] = arr[i];
visited[i] = 1;
findPermu(depth + 1);
visited[i] = 0;