solution.java 902 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
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 28 29 30 31 32 33 34 35 36
public class SuanShiJieFa {
    static int num = 0;

    public static void f1(int a[], int k) {
        double q;
        double w;
        double e;
        if (k == a.length - 1) {
            q = a[0];
            w = a[1] * 1.00 / a[2];
            e = (a[3] * 100 + a[4] * 10 + a[5]) * 1.00 / (a[6] * 100 + a[7] * 10 + a[8]);
            if (q + w + e == 10) {
                num++;
            }
        }
        for (int i = k; i < a.length; i++) {
            {
                int temp = a[i];
                a[i] = a[k];
                a[k] = temp;
            }
            f1(a, k + 1);
            {
                int temp = a[i];
                a[i] = a[k];
                a[k] = temp;
            }
        }
    }

    public static void main(String[] args) {
        int a[] = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        f1(a, 0);
        System.out.println(num);
    }
}