-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLietKeToHop1.java
More file actions
33 lines (33 loc) · 794 Bytes
/
LietKeToHop1.java
File metadata and controls
33 lines (33 loc) · 794 Bytes
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
package JAVA;
import java.util.*;
public class LietKeToHop1 {
public static int[] a=new int[1000];
public static int n;
public static int k;
public static int cnt=0;
public static void out(){
for(int i=1;i<=k;i++){
System.out.print(a[i]+" ");
}
System.out.println();
cnt++;
}
public static void Try(int i){
for(int j=a[i-1]+1;j<=n-k+i;j++){
a[i]=j;
if (i==k){
out();
}
else{
Try(i+1);
}
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
k=sc.nextInt();
Try(1);
System.out.println("Tong cong co "+cnt+" to hop");
}
}