求集合中的非空子集 Java

字符串的非空子集
import java.util.*;
public class _非空子集 {
    public static List sList = new ArrayList();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char car[] = null;
		car=sc.nextLine().toCharArray();
		Arrays.sort(car);
		gcd(car,0,"");
		System.out.println(sList);

	}
	private static void gcd(char[] car, int cut, String str) {
		if(cut==car.length)return;
		sList.add(str+car[cut]);
		gcd(car, cut+1, str+car[cut]);
		gcd(car, cut+1, str);
		
	}
}

你可能感兴趣的:(求集合中的非空子集 Java)