计时器,随机数

master
wei 5 years ago
parent f1d889513a
commit 9c1965bf2a

@ -0,0 +1,16 @@
package sort;
public class RandomNum {
public int[] RandomGen(int n,int low, int high){
int[] r=new int[n];
int diff=high-low;
for(int i=0;i<n;i++){
r[i]=(int) (Math.random()*diff)+low;
}
return r;
}
}

@ -0,0 +1,24 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sort;
/**
*
* @author User
*/
public class Stopwatch {
private final long start;
public Stopwatch(){
start=System.currentTimeMillis();
}
public double elapsedTime(){
long now=System.currentTimeMillis();
return (now-start)/1000.0;
}
}
Loading…
Cancel
Save