FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaReview/src/thinkingInJava/learning/prim1.java at main · ShellSort1998/JavaReview · GitHub
ShellSort1998
/
JavaReview
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaReview
/
src
/
thinkingInJava
/
learning
/
prim1.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (75 loc) · 1.94 KB
Breadcrumbs
JavaReview
/
src
/
thinkingInJava
/
learning
/
prim1.java
Copy path
File metadata and controls
80 lines (75 loc) · 1.94 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package
thinkingInJava
.
learning
;
import
java
.
util
.
Scanner
;
public
class
prim1
{
public
static
void
main
(
String
[]
args
) {
int
[][]
s
=
new
int
[
100
][
100
];
int
i
,
j
;
int
counter
=
2
,
startmin
=
1000
;
for
(
i
=
0
;
i
<
100
;
i
++)
{
for
(
j
=
0
;
j
<
100
;
j
++)
{
if
(
i
==
j
)
{
s
[
i
][
j
]=
0
;
}
else
{
s
[
i
][
j
]=
1000
;
}
}
}
int
[]
inthis
=
new
int
[
100
];
int
[]
tag
=
new
int
[
100
];
for
(
i
=
0
;
i
<
100
;
i
++)
{
tag
[
i
]=
1
;
}
Scanner
in
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"请输入点的数目"
);
int
n
=
in
.
nextInt
();
System
.
out
.
println
(
"请输入无向边,输入为0 0 0表示结束输入"
);
int
x
=
in
.
nextInt
();
int
y
=
in
.
nextInt
();
int
num
=
in
.
nextInt
();
for
(;!(
x
==
0
&&
y
==
0
);)
{
if
(
num
<
startmin
)
{
startmin
=
num
;
inthis
[
1
]=
x
;
inthis
[
2
]=
y
;
}
s
[
x
][
y
]=
num
;
s
[
y
][
x
]=
num
;
x
=
in
.
nextInt
();
y
=
in
.
nextInt
();
num
=
in
.
nextInt
();
}
tag
[
inthis
[
1
]]=
0
;
tag
[
inthis
[
2
]]=
0
;
System
.
out
.
println
(
inthis
[
1
]+
" "
+
inthis
[
2
]+
" "
+
startmin
);
int
tmp
=
1000
;
int
p
=
0
,
q
=
0
;
while
(
counter
<=
n
)
{
for
(
i
=
1
;
i
<=
counter
;
i
++)
{
for
(
j
=
1
;
j
<=
n
;
j
++)
{
if
((
s
[
inthis
[
i
]][
j
]<
tmp
)&&
tag
[
j
]==
1
&&
tag
[
inthis
[
i
]]==
0
)
{
tmp
=
s
[
inthis
[
i
]][
j
];
p
=
inthis
[
i
];
q
=
j
;
}
}
}
System
.
out
.
println
(
p
+
" "
+
q
+
" "
+
tmp
);
counter
++;
tag
[
q
]=
0
;
tmp
=
1000
;
inthis
[
counter
]=
q
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL