-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadixSort1.java
More file actions
45 lines (37 loc) · 1.28 KB
/
Copy pathRadixSort1.java
File metadata and controls
45 lines (37 loc) · 1.28 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
41
42
43
44
45
import java.io.*;
public class RadixSort1 {
public static void main(String[] args) {
LQueue[] radix = new LQueue[100000000];
try (BufferedReader bf = new BufferedReader(new FileReader("D:/temp/radix1.txt"))) {
String line;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
while ((line = bf.readLine()) != null) {
handleCommand(radix, line, pw);
break;
}
System.out.println(sw);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void handleCommand(LQueue[] queue, String command, PrintWriter pw) {
String[] parts = command.split(" ");
for(int i = 0; i<20000000;i++){
queue[i] = new LQueue();
}
for (String item : parts) {
try {
double num = Double.parseDouble(item);
queue[(int) num].enqueue(num);
} finally {
}
}
for (int i = 0; i < 20000000; i++) {
while (!queue[i].isEmpty()) {
Double value = queue[i].dequeue();
pw.print(value.longValue()+" ");
}
}
}
}