途虎编程第一题,自测没有任何问题,为啥贴到答题区,编译够都通不过,郁闷,把代码贴到下面,大家提提问题,感谢
import java.util.Arrays; import java.util.Scanner; /** * @Classname Main01 * @Description TODO * @Date 2020/9/10 19:36 * @Created by dreamBreathing */ public class Main01 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] str = sc.nextLine().split(","); int k = Integer.parseInt(str[0]); int n = Integer.parseInt(str[1]); System.out.println(Combination(n,k)); } private static int Combination(int n, int k){ if (k==0||k==n){ return 1; }else { return Combination(n-1,k)+Combination(n-1,k-1); } } }
全部评论
(3) 回帖