-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask9_8.java
More file actions
25 lines (22 loc) · 765 Bytes
/
Task9_8.java
File metadata and controls
25 lines (22 loc) · 765 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
import java.util.Arrays;
import static utils.Helper.fillMatrix;
public class Task9_8 {
public static void main(String[] args) {
int[][] array = new int[Integer.parseInt(args[0])][Integer.parseInt(args[0])];
fillMatrix(array);
System.out.println("Result: ");
System.out.println(Arrays.deepToString(zeroInTheEndOfLine(array)) + ";");
}
private static int[][] zeroInTheEndOfLine(int array[][]) {
for (int row[] : array) {
int counter = 0;
for (int i = 0; i < row.length; i++) {
if (row[i] != 0)
row[counter++] = row[i];
}
for (; counter < row.length; )
row[counter++] = 0;
}
return array;
}
}