1 //package j; 2 import java.util.*; 3 public class Main { 4 public static void main(String args[]){ 5 int r; 6 int c; 7 int r1; 8 int c1; 9 int r2; 10 int c2; 11 int i; 12 13 int while_num; 14 int num; 15 int j; 16 int k; 17 int num_1; 18 int[] sum; 19 Scanner cin = new Scanner(System.in); 20 while_num = cin.nextInt(); 21 for(num_1=0;num_1<while_num;num_1++){ 22 r = cin.nextInt(); 23 c = cin.nextInt(); 24 int[][]p=new int[r][c]; 25 for(i=0;i<r;i++) 26 for(j=0;j<c;j++){ 27 p[i][j] = cin.nextInt(); 28 } 29 num = cin.nextInt(); 30 sum = new int[num]; 31 for(j=0;j<num;j++){ 32 sum[j] = 0; 33 } 34 for(i = 0;i < num;i ++){ 35 r1 = cin.nextInt(); 36 c1 = cin.nextInt(); 37 r2 = cin.nextInt(); 38 c2 = cin.nextInt(); 39 for(j = r1-1;j <= r2-1;j++) 40 for(k = c1-1;k <= c2-1;k ++ ){ 41 sum[i] += p[j][k]; 42 } 43 44 45 46 47 } 48 for(j=0;j<num;j++){ 49 System.out.println("Absolutni hodnota pohodlnosti je "+sum[j]+" bodu."); 50 sum[j]=0; 51 } 52 System.out.println(); 53 } 54 55 } 56 }
时间: 2024-10-05 12:51:30