Last active
June 3, 2018 15:53
-
-
Save yorickshan/69d5f1fcdeee96afbf9ad55fb3908011 to your computer and use it in GitHub Desktop.
[Java] Java常用代码 #java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//初始化 | |
Scanner in = new Scanner(System.in); | |
//获取输入 | |
int a = in.nextInt(); | |
double b = in.nextDouble(); | |
//判断浮点数是否相等 | |
System.out.println(Math.abs(a-b) < 1e-6); //1e-6 为科学计数法,意为1*10^-6 | |
//随机数 | |
int number = (int)(Math.random()*100+1); // [0,1) -->[0,100) -->[1,100] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment