我是菜鸟的说……随便写了下……应该不是太好,可以改进的地方还很多……大家帮帮忙看看……public class BigArray { public static void main(String args[]) { int size = 100000; int[] bigArray = new int[size]; bigArray[0] = 1; for (int i = 1; i < size; i++) { bigArray[i] = -1;
} int tempCount = 0;
int k; for (int i = 999; i > 0; i--) { for (int j = 0; j < size; j++) { if (bigArray[j] == -1) { k = j; while (tempCount > 0) {
bigArray[k] = tempCount % 10;
tempCount = tempCount / 10;
k++;
}
break;
}
int tempMul = bigArray[j] * i;
tempCount = tempCount + tempMul;
bigArray[j] = tempCount % 10;
tempCount = tempCount / 10;
}
}

int i = size-1 ; while(i >= 0) {
if(bigArray[i] != -1){
System.out.print(bigArray[i]);
}
i -- ;
}
}
}

解决方案 »

  1.   

    1。
    int size = 100000; 既然是大数组当然是满足不同需求,把size定义为
    private static int SIZE_DEFINE先
    2。
     很难知道你写这么多是干吗(我也没兴趣看)。你只有一个main函数,你要做什么起码也给他封装一个方法,给他参数,然后用main去调用把。
      

  2.   

    private static final int SIZE_DEFINE先,漏了个final
      

  3.   

    我也写了个,不知正确否public class JieCheng { public static void main(String[] arg){
      int count = 10002;
      int flag = 10000;//进制
      int[] arrayValue = new int[count];
      int size = 1;
      int temp1 ;//余数
      int temp2 ;//高位数
      for(int i=0;i<count;i++){
      arrayValue[i] = -1;
      }
      for(int i=count;i>0;i--){
       for(int j=0;j<size;j++){
       if(arrayValue[j]==-1){
       arrayValue[j] = i;
       }else{
       arrayValue[j] = arrayValue[j]*i;
       } 
       
       }
       //进行格式化
       int length = size;
       for(int k=0;k<length;k++){
       if(arrayValue[k]>=flag){//满足进位
       temp1 =arrayValue[k]%flag;
       temp2 = arrayValue[k]/flag;
       if(arrayValue[k+1]==-1){
       size++;
       arrayValue[k+1] = temp2;
       }else{
       arrayValue[k+1] += temp2;
       }
       arrayValue[k] = temp1;
       }
       }
      }
      
      //读取结果集
      StringBuffer buf = new StringBuffer(1000);
      for(int i=size-1;i>=0;i--){
      buf.append(arrayValue[i]);
      }
      
      System.out.println("1000!");
      System.out.println("===================");
      System.out.println(buf.toString());
      System.out.println("===================");
      
      
    }

    }
      

  4.   


    有个很简单的办法,用BigInteger,
    并且还没有位数限制,多大都可以算,只不过效率可能不是很好:
    注意不要用递归,很容易StackOverFlowString p(int n) {
      if (n <= 1) {
        return "1";
      }
      String result = "1";
      for (int i = 1; i <= n; i ++){
        result = new BigInteger(result).multiply(BigInteger.valueOf(i)).toString();
      }
      return result;
    }