zoukankan      html  css  js  c++  java
  • 求两个数的百分比

      1.   int num1 = 7;  
      2.   
      3.         int num2 = 9;  
      4.   
      5.         // 创建一个数值格式化对象  
      6.   
      7.         NumberFormat numberFormat = NumberFormat.getInstance();  
      8.   
      9.         // 设置精确到小数点后2位  
      10.     
      11.         numberFormat.setMaximumFractionDigits(2);  
      12.   
      13.         String result = numberFormat.format((float) num1 / (float) num2 * 100);  
      14.   
      15.         System.out.println("num1和num2的百分比为:" + result + "%"); 
  • 相关阅读:
    1033.采药1
    G——胜利大逃亡 (BFS)
    POJ 3278 Catch That Cow
    C
    11.17 dfs poj1979 Red and Black
    11.11反思
    kmp笔记
    dfs bfs
    1113
    python 类方法
  • 原文地址:https://www.cnblogs.com/withoutaword/p/8822549.html
Copyright © 2011-2022 走看看