编写递归程序Java

2024-05-06 06:28:51
编写递归程序Java,麻烦给回复
写回答

最佳答案

public class bb {public static void main(String args[]){ System.out.println(getpower(2,10));}public static int getpower(int x,int y)//此为您要的递归方法{if(y==0)return 1;else if(y==1)return x;else return x*getpower(x,y-1);} }

2024-05-06 06:28:51
赞 4742踩 0

全部回答(1)