Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Arrays;
- public class SuperSet {
- public static int[] numberArray;
- public static int[] newNumberArray;
- public static int start;
- public static int end;
- public static boolean[] used;
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- numberArray = Arrays.stream(reader.readLine().split(", "))
- .mapToInt(Integer::parseInt)
- .toArray();
- start = 0;
- end = numberArray.length;
- for (int i = 1; i <= end; i++) {
- newNumberArray = new int[i];
- combination(0, start, i);
- }
- }
- private static void combination(int index, int start, int limit) {
- if (index == limit) {
- printArray();
- return;
- }
- for (int i = start; i < end; i++) {
- newNumberArray[index] = numberArray[i];
- combination(index + 1, i + 1, limit);
- }
- }
- private static void printArray() {
- for (int n : newNumberArray) {
- System.out.print(n + " ");
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment