-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuperficie du terrain.c
32 lines (30 loc) · 987 Bytes
/
Superficie du terrain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <stdlib.h>
int main()
{
int Aeroport[4], N;
for (int i = 0; i < 4; i++)
scanf("%d", Aeroport + i);
scanf("%d", &N);
int Prive[N][4], surface = (Aeroport[2] - Aeroport[0]) * (Aeroport[3] - Aeroport[1]);
for (int i = 0; i < N; i++)
{
for (int j = 0; j < 4; j++)
scanf("%d", Prive[i] + j);
if (Prive[i][0] > Aeroport[2] || Prive[i][1] > Aeroport[3])
continue;
if (Prive[i][2] < Aeroport[0] || Prive[i][3] < Aeroport[1])
continue;
if (Prive[i][0] < Aeroport[0])
Prive[i][0] = Aeroport[0];
if (Prive[i][1] < Aeroport[1])
Prive[i][1] = Aeroport[1];
if (Prive[i][2] > Aeroport[2])
Prive[i][2] = Aeroport[2];
if (Prive[i][3] > Aeroport[3])
Prive[i][3] = Aeroport[3];
surface -= (Prive[i][2] - Prive[i][0]) * (Prive[i][3] - Prive[i][1]);
}
printf("%d", surface);
return 0;
}