1 package pack; 2 import java.util.*; 3 4 public class demo_1 { 5 static int r,n; 6 static int a[]=new int [100]; 7 static int b[]=new int[100]; 8 static void f(int point,int picked) { 9 if(picked==r) { 10 for(int i=0;i<r;i++) 11 System.out.print(b[i]+" "); 12 System.out.println(); 13 return ; 14 } 15 for(int i=point;i<n;i++) { 16 b[picked]=a[i]; 17 f(i+1,picked +1); 18 } 19 } 20 21 public static void main(String[] args) { 22 Scanner in = new Scanner(System.in); 23 System.out.print("请输入N的值:"); 24 n=in.nextInt(); 25 System.out.println("请输入数组的"+n+"个值:"); 26 for(int i=0;i<n;i++) 27 a[i]=in.nextInt(); 28 29 System.out.print("请输入R的值"); 30 r=in.nextInt(); 31 f(0,0); 32 33 } 34 }