假设我有两个列表:
x = [[1,2,3],[5,4,20],[9,100,7]]
y = [[1,1,1],[1,1,1],[1,1,1]]
我试图z = x - y
让我的数组应该像
z = [[0, 1, 2], [4, 3, 19], [8, 99, 6]]
假设我有两个列表:
x = [[1,2,3],[5,4,20],[9,100,7]]
y = [[1,1,1],[1,1,1],[1,1,1]]
我试图z = x - y
让我的数组应该像
z = [[0, 1, 2], [4, 3, 19], [8, 99, 6]]
例如在 Java 中
public class Main {
public static void main(String[] args) {
int[][] x = new int[][]{
{1,2,3},
{5,4,20},
{9,100,7}
};
int[][] y = new int[][]{
{1,1,1},
{1,1,1},
{1,1,1}
};
int[][] result = new int[3][3];
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
result[i][j] = x[i][j] - y[i][j];
System.out.print(result[i][j]+ " ");
}
System.out.print(" | ");
}
}
}