-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq.java
More file actions
27 lines (23 loc) · 722 Bytes
/
q.java
File metadata and controls
27 lines (23 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.ArrayList;
public class q {
public static void main(String[] args) {
ArrayList<String> a = new ArrayList<> ();
boolean[]f = new boolean[3];
alpha(new String []{"c " , "a" , "r"} , 0 , a, f);
}
private static void alpha(String[] s, int i, ArrayList<String> a , boolean [] f) {
if(a.size () - 1== s.length - 1){
System.out.println (a);
return;
}
for (int j = 0; j <s.length ; j++) {
if (f[j] == false) {
f[j] = true;
a.add (s[j]);
alpha (s, i + 1, a, f);
a.remove (a.size () - 1);
f[j] = false;
}
}
}
}