數(shù)據(jù)加載中……

          BigIntegerTest.java

          /*

          *用戶輸入兩個數(shù)字,程序?qū)⑼ㄖ阒歇劦臋C(jī)率有多大
          */
          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ù)
          /*中獎計(jì)算公式
          (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("你的中獎機(jī)率為每" + option + "次中有一次!"); System.out.println("祝你好運(yùn)!"); System.exit(0); }}

          posted @ 2008-10-20 12:47 郭興華 閱讀(111) | 評論 (0)編輯 收藏
          java1.6省去了包裝類

          import java.util.*;
          public class BaoZhuang{
              public static void main(String[] args)
              {
                  Vector a=new Vector();
                  a.add("123");
                  a.add(244);
              }
          }
          這樣寫在1.4運(yùn)行環(huán)境下,是不能通過的
          但在1.6運(yùn)行環(huán)境下,卻可以。

          posted @ 2008-10-16 08:21 郭興華 閱讀(192) | 評論 (0)編輯 收藏
          測試自增、自減操作

          /*
          *測試自增、自減操作
          */
          public class SelfAction
          {
           public static void main(String[] args)
           {
            int x = 10;
            int a = x + x++;
            System.out.println("a=" + a);
            System.out.println("x=" + x);
            int b = x + ++x;
            System.out.println("b=" + b);
            System.out.println("x=" + x);
            int c = x + x--;
            System.out.println("c=" + c);
            System.out.println("x=" + x);
            int d = x + --x;
            System.out.println("d=" + d);
            System.out.println("x=" + x); 


           }
          }
          輸出 是
          a=20
          x=11
          b=23
          x=12
          c=24
          x=11
          d=21
          x=10

          posted @ 2008-10-13 07:06 郭興華 閱讀(123) | 評論 (0)編輯 收藏
          welcome.java

          public class Welcome
          {
            public static void main(String[] args)
            {
              System.out.println("這是你的第一個程序,歡迎你走入Java的大門");
            }
          }

          posted @ 2008-10-09 10:30 郭興華 閱讀(141) | 評論 (0)編輯 收藏
          僅列出標(biāo)題
          共9頁: 上一頁 1 2 3 4 5 6 7 8 9 
          主站蜘蛛池模板: 临邑县| 通州区| 南京市| 桐乡市| 拜泉县| 新闻| 崇州市| 阳春市| 东丽区| 宜昌市| 扎兰屯市| 安陆市| 孙吴县| 沐川县| 比如县| 策勒县| 黄陵县| 邢台县| 读书| 内丘县| 无极县| 江华| 琼中| 仪陇县| 万年县| 凌源市| 集安市| 四子王旗| 静安区| 城固县| 襄城县| 北辰区| 洪雅县| 哈尔滨市| 铁力市| 裕民县| 汕头市| 广河县| 新泰市| 建水县| 桃园市|