FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java_Programs/UshapedLayersMatrix.java at main · prittoruban/Java_Programs · GitHub
prittoruban
/
Java_Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java_Programs
/
UshapedLayersMatrix.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (31 loc) · 1.11 KB
Breadcrumbs
Java_Programs
/
UshapedLayersMatrix.java
Copy path
File metadata and controls
33 lines (31 loc) · 1.11 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
import
java
.
util
.
Scanner
;
public
class
UshapedLayersMatrix
{
public
static
void
main
(
String
[]
args
) {
Scanner
scanner
=
new
Scanner
(
System
.
in
);
int
R
=
scanner
.
nextInt
();
int
C
=
scanner
.
nextInt
();
int
[][]
matrix
=
new
int
[
R
][
C
];
for
(
int
i
=
0
;
i
<
R
;
i
++) {
for
(
int
j
=
0
;
j
<
C
;
j
++) {
matrix
[
i
][
j
] =
scanner
.
nextInt
();
}
}
printULayers
(
matrix
,
R
,
C
);
}
private
static
void
printULayers
(
int
[][]
matrix
,
int
R
,
int
C
) {
int
top
=
0
,
bottom
=
R
-
1
,
left
=
0
,
right
=
C
-
1
;
while
(
left
<
right
&&
bottom
>=
0
) {
for
(
int
i
=
top
;
i
<=
bottom
;
i
++) {
System
.
out
.
print
(
matrix
[
i
][
left
] +
" "
);
}
for
(
int
i
=
left
+
1
;
i
<=
right
;
i
++) {
System
.
out
.
print
(
matrix
[
bottom
][
i
] +
" "
);
}
for
(
int
i
=
bottom
-
1
;
i
>
top
;
i
--) {
System
.
out
.
print
(
matrix
[
i
][
right
] +
" "
);
}
System
.
out
.
println
();
bottom
--;
left
++;
right
++;
}
}
}
Back
|
FazBrowse Home
|
New Git URL