public static long func(long x){
  long iResult = 0;
if(x > 90)
   iResult = x-10;
if(0<= x && x <= 90)
   iResult = Func(Func(x+11));
  
  return iResult;
}

解决方案 »

  1.   

    如果x<0呢?public static long func(long x){
      long iResult = 0;
      if(x > 90){
        iResult = x-10;
      }else if(x>=0 && x<= 90){
        iResult = func(func(x + 11));
      }
      return iResult;
    }
      

  2.   

    小于零不用判断
     public static long funC(long x) {
        long iResult = 0;
        if (x >= 0) {
          if (x > 90) {
            iResult = x - 10;
          }
          else {
            iResult = funC(funC(x+11));
          }
        }
        return iResult;
      }
    怎么写更加简洁
      

  3.   

    public static long func(long x){
      if(x >= 0){
        return x>90 ? (x-10) : func(func(x+11));
      }else {
        return 0;
      }}