-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProblema_1072.cpp
67 lines (52 loc) · 953 Bytes
/
Problema_1072.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
61
62
63
64
65
66
67
/*
@autor: Victor E. B. Rodrigues;
@data: 24/06/2021;
@nome: Intervalo 2;
*/
#include <bits/stdc++.h>
using namespace std;
template<class T>
class Intervalo{
private:
T comeco;
T fim;
public:
Intervalo(){}
Intervalo(T comeco, T fim){
this->comeco = comeco;
this->fim = fim;
}
T getComeco(){
return comeco;
}
T getFim(){
return fim;
}
};
template<class T>
class IntervaloFechado:public Intervalo<T>{
public:
IntervaloFechado<T>(T x, T y) : Intervalo<T>(x,y){}
bool contains(T &num){
if(num >= this->getComeco() && num <= this->getFim())
return true;
return false;
}
};
int main(){
cin.tie(NULL);
cout.tie(NULL);
ios::sync_with_stdio(0);
int N, X, arr[2] = {0,0};
IntervaloFechado<int> intervalo(10,20);
cin >> N;
for(int i = 0; i < N; i++){
cin >> X;
if(intervalo.contains(X))
arr[0]++;
else
arr[1]++;
}
cout << arr[0] << " in\n" << arr[1] << " out" << endl;
return 0;
}