-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWaveDisplay.java
More file actions
41 lines (35 loc) · 956 Bytes
/
WaveDisplay.java
File metadata and controls
41 lines (35 loc) · 956 Bytes
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
package lecture5;
import java.util.Scanner;
public class WaveDisplay {
static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
int[][] arr = takeinput();
ROWdisplay(arr);
}
public static int[][] takeinput() {
System.out.println("rows?");
int rows = s.nextInt();
System.out.println("cols?");
int cols = s.nextInt();
int[][] arr = new int[rows][cols];
for (int row = 0; row < arr.length; row++) {
for (int col = 0; col < arr[0].length; col++) {
System.out.println("arr[" + row + "-" + col + "]");
arr[row][col] = s.nextInt();
}
}
return arr;
}
public static void ROWdisplay(int[][] arr) {
for (int col = 0; col < arr[0].length; col++) {
if (col % 2 == 0)
for (int row = 0; row < arr.length; row++) {
System.out.println(arr[row][col] + " ");
}
else
for (int row = arr.length - 1; row >= 0; row--) {
System.out.println(arr[row][col] + " ");
}
}
}
}