1.常见的很容易理解的求阶层
package ee;
import java.util.Scanner;
public class Rucursive {
int sum=1;
public int compute(int n) {
if(n==0) {
return 1;
}
return sum=n*compute(--n);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("请输入需要递归求解的数:");
int n=sc.nextInt();
int result=new Rucursive().compute(n);
System.out.println("结果是:"+result);
}
}
理解不难,实现理解不难。反正自己当时没理解实现过程方法的压栈弹栈操作
package ee;
import java.util.Scanner;
public class Rucursiv {
static int m=0;
public static void move(int disks,int p2,int p3