-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6.1.4.1 Includes operations
40 lines (36 loc) · 1.08 KB
/
6.1.4.1 Includes operations
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
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
struct Country
{
string name;
int area;
};
bool compare(Country lhs, Country rhs)
{
return lhs.area < rhs.area;
}
int main()
{
vector <Country> countries = {
{ "India", 3287 },{ "Argentina", 2780 },
{ "Brazil", 8515 },{ "Australia", 7692 },
{ "China", 9572 },{ "United States of America", 9525 },
{ "Russia", 17098 },{ "Canada", 9984 },
{ "Kazakhstan", 2724 },{ "Algeria", 2381 }
};
vector <Country> countries_small = {
{ "Brazil", 8515 },{ "Australia", 7692 },
{ "Kazakhstan", 2724 },{ "Algeria", 2381 }
};
sort(countries.begin(), countries.end(),compare);
sort(countries_small.begin(), countries_small.end(),compare);
if (includes(countries.begin(), countries.end(), countries_small.begin(), countries_small.end(), compare))
cout << "Second vector included." << endl;
else
cout << "Second vector not included." << endl;
return 0;
}