假设我有两个列表:
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]]
答案 0 :(得分:-1)
例如在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(" | ");
}
}
}