public class EchoPlayer {static int M = 5; static int N = 4;static int[][] b = new int[5][N];static int k=0;public static void main(String[] args){C(5,4,4);System.out.println();for(int i=0;i<5;i++){for(int j=0;j<N;j++){System.out.print(b[i][j]+" ");} System.out.println();}}static void C(int m,int n,int T){int i,j;for(i=n;i<=m;i++) {b[k][n-1] = i;if(n>1)C(i-1,n-1,T);else {for(j=0;j<=T-1;j++){System.out.print(b[k][j] + " ");} System.out.println();k++;} }}} 輸出:1 2 3 4 1 2 3 5 1 2 4 0 1 3 0 0 2 0 0 01 2 3 4 1 2 3 5 1 2 4 0 1 3 0 0 2 0 0 0他應該輸出1 2 3 4 5取出4個數的組合,一共五種情況,為啥從第三種開始就有的位置為零了。
這個程序輸出為何不對?
慕斯709654
2018-07-20 11:08:23