-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTest.java
More file actions
40 lines (36 loc) · 1.5 KB
/
Test.java
File metadata and controls
40 lines (36 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.*;
public class Test{
public static void main(String args[])
{
Random digit=new Random();
int num,temp;
int[] a;
a=new int[1000];
for(int i=0;i<999;++i)
{
num=999+digit.nextInt(9999);
a[i]=num;
}
//sort
long lStartTime;
lStartTime = System.nanoTime();
for (int k=0;k<=998;k++)
{
for (int i=0;i<=998-k;i++)
{
if (a[i]>a[i+1])
{
temp = a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
}
for(int j=0;j<999;++j)
System.out.println(a[j]);
long lEndTime;
lEndTime= System.nanoTime();
long output= lEndTime -lStartTime;
System.out.println(output);
}
}