FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs-1/String/Colindrome.java at master · Scarlet-Coder/Java-Programs-1 · GitHub
Scarlet-Coder
/
Java-Programs-1
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-1
/
String
/
Colindrome.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (51 loc) · 1.12 KB
Breadcrumbs
Java-Programs-1
/
String
/
Colindrome.java
Copy path
File metadata and controls
56 lines (51 loc) · 1.12 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
package
String
;
import
java
.
util
.
Scanner
;
public
class
Colindrome
{
public
static
String
[]
split
(
String
s
) {
String
t
=
""
;
String
r
[] =
new
String
[(
s
.
length
() /
6
)];
for
(
int
i
=
0
;
i
<
s
.
length
() /
6
;) {
for
(
int
j
=
0
;
j
<
s
.
length
();
j
++) {
if
((
j
+
1
) %
6
==
0
) {
t
+=
s
.
charAt
(
j
);
r
[
i
++] =
t
;
t
=
""
;
}
else
t
+=
s
.
charAt
(
j
);
}
}
for
(
String
x
:
r
) {
System
.
out
.
println
(
x
);
}
return
r
;
}
public
static
void
main
(
String
[]
args
) {
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Enter the String: "
);
String
s
=
sc
.
nextLine
();
sc
.
close
();
int
flag
=
0
;
if
(
s
.
length
() <
6
&& (
s
.
length
() %
6
!=
0
))
System
.
out
.
println
(
"Not a colindrome!"
);
String
[]
res
=
split
(
s
);
for
(
int
i
=
0
;
i
<
res
.
length
;
i
++) {
if
(!
isColindrome
(
res
[
i
]))
flag
=
1
;
}
if
(
flag
==
0
) {
System
.
out
.
println
(
"String is colindrome"
);
}
else
{
System
.
out
.
println
(
"Not a colindrome!"
);
}
}
public
static
boolean
isColindrome
(
String
s
) {
int
k
=
2
,
j
=
3
;
while
(
k
>
0
) {
if
(
s
.
charAt
(
k
) !=
s
.
charAt
(
j
))
return
false
;
k
--;
j
++;
}
return
true
;
}
}
Back
|
FazBrowse Home
|
New Git URL