forked from shikaruki/Hactoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheStateOfWakanda1.java
55 lines (40 loc) · 999 Bytes
/
TheStateOfWakanda1.java
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
import java.util.Scanner;
public class TheStateOfWakanda1 {
public static void Display(int [][] a)
{
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[0].length; j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int row = scn.nextInt();
int coloumn = scn.nextInt();
int [][] twodArray = new int[row][coloumn];
for (int i = 0; i < twodArray.length; i++) {
for (int j = 0; j < twodArray[0].length; j++) {
twodArray[i][j] = scn.nextInt();
}
}
for(int j = 0; j<twodArray[0].length;j++)
{
if(j % 2 == 0)
{
for (int i = 0; i < twodArray.length; i++)
{
System.out.println(twodArray[i][j]);
}
}
else
{
for (int i = twodArray.length-1; i >=0; i--)
{
System.out.println(twodArray[i][j]);
}
}
}
}
}