zoukankan      html  css  js  c++  java
  • 大数值

    API

    java.math.BigInteger

    BigInteger add(BigInteger other)

    BigInteger subtract(BigInteger other)

    BigInteger multiply(BigInteger other)

    BigInteger divide(BigInteger other)

    BigInteger mod(BigInteger other)

    int compareTo(BigInteger other)

    static BigInteger valueOf(long x)

     1 import java.math.BigInteger;
     2 import java.util.Scanner;
     3 
     4 
     5 public class BigIntegerTest {
     6 
     7     /**
     8      * @param args
     9      */
    10     public static void main(String[] args) {
    11         // TODO Auto-generated method stub
    12 
    13         Scanner in = new Scanner(System.in);
    14         
    15         System.out.print("How many numbers do you need to draw?");
    16         int k = in.nextInt();
    17         
    18         System.out.print("What is the highest number you can draw?");
    19         int n = in.nextInt();
    20         
    21         BigInteger lotteryOdds = BigInteger.valueOf(1);
    22         
    23         for(int i = 1;i<k;i++) {
    24             lotteryOdds = lotteryOdds.multiply(BigInteger.valueOf(n-i+1)).divide(BigInteger.valueOf(i));
    25             
    26             System.out.println("your odds are 1 in "+lotteryOdds+".Good luck!!");
    27         }
    28     }
    29 
    30 }
  • 相关阅读:
    DOM编程
    BOM编程
    JavaScript
    CSS
    HTML入门
    shiro与项目集成开发
    shiro授权测试
    散列算法
    shiro认证流程
    spring boot 入门及示例
  • 原文地址:https://www.cnblogs.com/linst/p/4966456.html
Copyright © 2011-2022 走看看