实验 3

1.for循环

2.while 循环

 

3.do-while  

4.递归

  System.out.print("请输入a的值:");

  int a=scanner.nextInt();

  System.out.println("用递归方法输出阶乘的值:"+Recursion(a));

 }

 public static int Recursion(int b)

 {

  if(b==0) return 1;

  else return b*Recursion(b-1);

  }

5.实验心得

         本次实验用四种方法完成n的阶乘,第四种用递归方法调试的时候,多次调试运行,仍然有错,没有得出结论,会继续找错调试。

     

 

posted @ 2019-03-24 23:17  cxm&  阅读(109)  评论(1编辑  收藏  举报