算法训练(大富翁)

题目:

 

 

代码:

 

 

import java.util.Scanner;

public class DaFuWong {
static int t = 0;
static int to = 0;
public static void main(String[] args) {
int n=new Scanner(System.in).nextInt();

int[] a = new int[n];
fu(n);
System.out.println(t);
}

private static void fu(int n) {
for (int i = 1; i < 7; i++) {
if(to<n){
to += i;
fu(n);
to -= i;
}else if(to>n){
continue;
}else{
t++;
return;
}
}
}
}

 

posted @ 2017-08-29 17:46  rainbowxch  阅读(573)  评论(0编辑  收藏  举报