-1

假设我有两个列表:

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]]
4

1 回答 1

-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(" | ");
    }

}

}

于 2013-11-07T12:55:26.610 回答