标签:矩形 image static count com main src code ati
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
boolean [][] flag = new boolean[105][105];
int count = 0;
for(int i=0;i<n;i++) {
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int x2 = sc.nextInt();
int y2 = sc.nextInt();
//矩形全部涂色
for(int j=y1;j<y2;j++) {
for(int k=x1;k<x2;k++) {
flag[j][k] = true;
}
}
}
for(int i=0;i<flag.length;i++) {//遍历全部行数
for(int j=0;j<flag[i].length;j++) {//遍历全部列数
if(flag[i][j]) {//只会算一次
count++;
}
}
}
sc.close();
System.out.println(count);
}
}
标签:矩形 image static count com main src code ati
原文地址:https://www.cnblogs.com/yu-jiawei/p/12343195.html