-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatriceRighe.java
45 lines (36 loc) · 1.06 KB
/
MatriceRighe.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
package Array;
public class MatriceRighe {
public static void main(String[] args) {
int[][] m = {{1,2,3,4},
{1,2,3,4},
{1,2,3,4},
{1,2,3,4},
{1,2,3,4}};
int[] a = {0,2};
// visualizza(m);
// righe(m,a);
System.out.println("*****************");
azzeraRighe(m, 2);
visualizza(m);
}
public static void righe(int[][] m, int[] a) {
for(int i = 0; i < a.length; i++){
for(int j = 0; j < m[i].length; j++) {
m[a[i]][j] = 0;
}
}
}
public static void visualizza(int[][] m) {
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
System.out.print(m[i][j] + " ");
}
System.out.println();
}
}
public static void azzeraRighe(int[][] m, int k) {
for(int j = 0; j < m[k].length; j++) {
m[k][j] = 0;
}
}
}