1

私のプログラミングクラスでは、入力/出力を処理するメインメソッド、計算するメソッドを使用して、組み合わせ関数 C(n,k) = n!/(k!*(nk)!) を計算するプログラムを作成する必要があります。階乗、および組み合わせ関数を計算する方法。これが私のコードです:

import java.util.Scanner;
public class Combinations {

    public static void factorials (int set, int objects) {
        Scanner keyboard = new Scanner(System.in);
        int n = set;
        int k = objects;
        int c = (n-k);
        int factorial1 = 1;
        int factorial2 = 1;
        int factorial3 = 1;
        while (n > 0) {
            factorial1 = factorial1 + s;
            n = n++;
        }//while loop
        while (k > 0) {
            factorial2 = factorial2 + o;
            k = k++;
        }//while loop
        while (c > 0) {
            factorial3 = factorial3 + c;
            c = c++;
        }//while loop
        System.out.println(Combinations(factorial1,factorial2,factorial3));
    }//method factorials
    public static int Combinations (int set, int objects, int x){
        int n = set;
        int k = objects;
        int c = x;
        int combination;
        combination = n/(k*c);
        return combination;
    }//method Combinations
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter the number of integers in a set: ");
        int n = keyboard.nextInt();
        System.out.println("Enter the number of objects to be chosen from the set: ");
        int k = keyboard.nextInt();
        System.out.println(factorials(n,k));
    }//method main

}//class

私の問題は、System.out.println(factorials(s,o));「PrintStream 型のメソッド println(boolean) は引数 (void) には適用できません」というエラー メッセージが表示されることです。なぜこれを言っているのかわかりません。ヘルプ?

4

2 に答える 2