數(shù)據(jù)加載中……
          BigIntegerTest.java
          /*
          *用戶輸入兩個數(shù)字,程序?qū)⑼ㄖ阒歇劦臋C率有多大
          */
          import javax.swing.*;
          import java.math.*;
          public class BigIntegerTest{
          public static void main(String[] args){
          String input =JoptionPane.showInputDialog("請輸入彩球總數(shù):");
          int n=Inter.parseInt(input);//將字符串轉(zhuǎn)化為整數(shù)
          /*中獎計算公式
          (n*(n-1)*(n-2)*...*(n-m+1))/(1*2*...*m)
          */
          BigInteger option =BigInteger.valueOf(1);
          for(int i=0;i<m;i++){
          option=option.multiply(BigInteger.valueOf(n-i)).divide(BigInteger.valueOf(i+1));}
          System.out.println("你的中獎機率為每" + option + "次中有一次!"); System.out.println("祝你好運!"); System.exit(0); }}

          posted on 2008-10-20 12:47 郭興華 閱讀(111) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 博客| 霍州市| 安宁市| 凤庆县| 那坡县| 阜康市| 略阳县| 登封市| 云南省| 新龙县| 旬阳县| 乃东县| 广平县| 饶河县| 额济纳旗| 宜兴市| 公主岭市| 元氏县| 元江| 柳州市| 邳州市| 清水河县| 中超| 雷波县| 三明市| 克拉玛依市| 南汇区| 迁西县| 都江堰市| 新兴县| 尚义县| 德州市| 湟源县| 诸暨市| 宜宾市| 尼木县| 兰坪| 东丰县| 平湖市| 安陆市| 浠水县|