JAVA基础
JAVA打好基础很重要
sandy_zhang123
这个作者很懒,什么都没留下…
展开
-
最大公约数
求最大公约数和最小公倍数public class first {public static void main(String []args){ int a = 12; int b = 18; while(b!=0){ int temp = a%b; a = b; b = temp; } int num = a; System.out.println(num); ...原创 2022-03-08 19:24:33 · 81 阅读 · 0 评论 -
java格式化输出
1.对于数字 1.四舍五入法表示 DecimalFormat df = new DecimalFormat("##.000"); 代表小数点前保留两位,小数点后保留三位 eg:23.523 2.百分号表示 System.out.println(new DecimalFormat("#.##%").format(pi)); eg:314.16% 3.科学计数法 long c...原创 2020-02-29 21:17:56 · 197 阅读 · 0 评论