Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SubSet {
- public void findSubSet(int[] a, Integer[] subSet, int i) {
- if (i == a.length) {
- printResult(subSet);
- }
- else {
- subSet[i] = (Integer) null;
- subSet(a, subSet, i + 1);
- subSet[i] = a[i];
- subSet(a, subSet, i + 1);
- }
- }
- public void printResult(Integer[] subSet) {
- for (int i = 0; i < subSet.length; i++) {
- if (subSet[i] != null)
- System.out.print(subSet[i] + " ");
- }
- System.out.println();
- }
- public static void main(String[] args) {
- int[] a = { 4, 1, -1, 6, 2, -2, 3, -3, -4, -6 };
- new SubSet().findSubSet(a, new Integer[a.length], 0);
- }
- }
Add Comment
Please, Sign In to add comment