Skip to content

Instantly share code, notes, and snippets.

@yorickshan
Last active June 3, 2018 15:53
Show Gist options
  • Save yorickshan/69d5f1fcdeee96afbf9ad55fb3908011 to your computer and use it in GitHub Desktop.
Save yorickshan/69d5f1fcdeee96afbf9ad55fb3908011 to your computer and use it in GitHub Desktop.
[Java] Java常用代码 #java
//初始化
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