FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SortAlgorithms/src/Main.java at master · Stackneveroverflow/SortAlgorithms · GitHub
Stackneveroverflow
SortAlgorithms
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SortAlgorithms
/
src
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (35 loc) · 1.2 KB
Breadcrumbs
SortAlgorithms
/
src
/
Main.java
Copy path
File metadata and controls
37 lines (35 loc) · 1.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
io
.
FileOutputStream
;
import
java
.
io
.
IOException
;
import
java
.
io
.
PrintWriter
;
import
java
.
util
.
Random
;
/**
* Main
*
* @author Macer
* @version V1.1
* @date 2018/05/05 16:09
*/
public
class
Main
{
public
static
void
main
(
String
[]
args
) {
Integer
[]
a
=
new
Integer
[
10000000
];
Random
rand
=
new
Random
(
System
.
currentTimeMillis
());
// 伪随机数填充数组
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++) {
a
[
i
] =
rand
.
nextInt
(
99999999
);
}
// 复制多组相同的原始伪随机序列
Integer
[][]
aa
=
new
Integer
[
10
][
a
.
length
];
for
(
int
i
=
0
;
i
<
aa
.
length
;
i
++) {
// System.arraycopy方法是native方法,比clone()更高效,Arrays.copyOf调用该方法
// 传入参数(源数组,源数组起始位置,目的数组,目的数组起始位置,复制长度)都是浅拷贝
System
.
arraycopy
(
a
,
0
,
aa
[
i
],
0
,
a
.
length
);
}
try
(
PrintWriter
sortResult
=
new
PrintWriter
(
new
FileOutputStream
(
"SortResult.txt"
));
) {
SortDemo
.
print
(
sortResult
,
aa
);
}
catch
(
IOException
ioe
) {
ioe
.
printStackTrace
();
}
}
}
Back
|
FazBrowse Home
|
New Git URL