FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/String/LargeWordCount.java at master · githubanalyzeruser/Java-Programs · GitHub
githubanalyzeruser
/
Java-Programs
Public
forked from
divScorp/Java-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
String
/
LargeWordCount.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (60 loc) · 1.26 KB
Breadcrumbs
Java-Programs
/
String
/
LargeWordCount.java
Copy path
File metadata and controls
63 lines (60 loc) · 1.26 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
package
String
;
public
class
LargeWordCount
{
public
static
String
[]
split
(
String
s
) {
int
c
=
0
;
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++) {
if
(
s
.
charAt
(
i
) ==
' '
)
c
++;
}
String
[]
temp
=
new
String
[
c
+
1
];
String
t
=
""
;
int
i
=
0
;
for
(
int
j
=
0
;
j
<
s
.
length
();
j
++) {
if
(
s
.
charAt
(
j
) !=
' '
) {
t
+=
s
.
charAt
(
j
);
}
else
{
temp
[
i
++] =
t
;
t
=
""
;
}
}
temp
[
i
] =
t
;
return
temp
;
}
public
static
void
sort
(
String
[]
s
) {
for
(
int
j
=
0
;
j
<
s
.
length
;
j
++) {
for
(
int
i
=
0
;
i
<
s
.
length
-(
j
+
1
);
i
++) {
if
(
s
[
i
].
length
()>
s
[
i
+
1
].
length
()) {
String
t
=
s
[
i
];
s
[
i
]=
s
[
i
+
1
];
s
[
i
+
1
]=
t
;
}
}
}
}
public
static
String
sortAndCount
(
String
[]
sp
) {
sort
(
sp
);
String
sx
=
""
;
int
n
;
for
(
int
k
=
0
;
k
<
sp
.
length
-
1
;
k
++) {
if
(
sp
[
k
].
length
()!=
sp
[
k
+
1
].
length
()) {
n
=
sp
[
k
].
length
();
sx
+=
sp
[
k
]+
n
+
" "
;
}
else
{
sx
+=
sp
[
k
]+
" "
;
}
}
sx
+=
sp
[
sp
.
length
-
1
]+
sp
[
sp
.
length
-
1
].
length
();
return
sx
;
}
public
static
void
main
(
String
[]
args
) {
String
s
=
"the white tiger is bigger than the brown tiger"
;
// output : is 2 the 3 than 4 white tiger brown 5 bigger 6
String
[]
sp
=
split
(
s
);
for
(
String
n
:
sp
) {
System
.
out
.
print
(
n
+
" "
);
}
System
.
out
.
println
();
String
res
=
sortAndCount
(
sp
);
System
.
out
.
println
(
res
);
}
}
Back
|
FazBrowse Home
|
New Git URL