java递归算法,代码如下:
public class Test3 { public double zhishu(double x,double y){ if(y>0){ return x*zhishu(x,y-1); }else if(y<0){ return (x*zhishu(x,-y-1)); }else{ return 1; } } public double fuzhishu(double x,double y){ double i=zhishu(x,y); return 1/i; } public double action(double x,double y){ if(y>0){ return zhishu(x,y); }else if(y<0){ return fuzhishu(x,y); }else{ return 1; } } public static void main(String[] args) { // TODO Auto-generated method stub Test3 t3=new Test3(); ((-3,2)); } }