我效率好低 是不是太笨了 希望理解力upupup
谢谢y老师和徐老师??
切接 close(),不然过不了
import java.util.*;
public class Main{
private static int N = 1010;
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int q = scan.nextInt();
int[][] arr = new int[N][N];
int[][] dif = new int[N][N];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
arr[i][j] = scan.nextInt();
insert(i, j, i, j, dif, arr[i][j]);
}
}
while(q -- > 0){
int x1 = scan.nextInt();
int y1 = scan.nextInt();
int x2 = scan.nextInt();
int y2 = scan.nextInt();
int t = scan.nextInt();
insert(x1, y1, x2, y2, dif, t);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
dif[i][j] = dif[i][j] + dif[i - 1][j] + dif[i][j - 1] - dif[i - 1][j - 1];
System.out.print(dif[i][j] + " ");
}
System.out.println();
}
scan.close();
}
private static void insert(int x1, int y1, int x2, int y2, int[][] dif, int t){
dif[x1][y1] += t;
dif[x1][y2 + 1] -= t;
dif[x2 + 1][y1] -= t;
dif[x2 + 1][y2 + 1] += t;
}
}
?
?
|