-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathmacaco.cpp
60 lines (42 loc) · 1.16 KB
/
macaco.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, test=1;
cin >> n;
while (n) {
vector< vector<int> > retangulos;
int temp;
for (int i = 0; i < n; i++) {
vector<int> points;
int time = 4;
while (time--) {
cin >> temp;
points.push_back(temp);
}
retangulos.push_back(points);
}
int point1x=-10001, point1y=10001, point2x=10001, point2y=-10001;
for (int i = 0; i < n; i++) {
if (retangulos[i][0] > point1x && retangulos[i][1] < point1y) {
point1x = retangulos[i][0];
point1y = retangulos[i][1];
}
if (retangulos[i][1] < point2x && retangulos[i][3] > point2y) {
point2x = retangulos[i][2];
point2y = retangulos[i][3];
}
}
cout << "Teste " << test << endl;
int correct=0;
for (int i = 0; i < n; i++) {
if (point1x >= retangulos[i][0] && point1y <= retangulos[i][1] && point2x <= retangulos[i][2] && point2y >= retangulos[i][3]) correct++;
}
if (correct != n) cout << "nenhum" << endl << endl;
else cout << point1x << " " << point1y << " " << point2x << " " << point2y << endl << endl;
cin >> n;
test++;
}
return 0;
}