-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimalIdentificationExpertSystem.cpp
More file actions
41 lines (37 loc) · 1 KB
/
Copy pathAnimalIdentificationExpertSystem.cpp
File metadata and controls
41 lines (37 loc) · 1 KB
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
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
map<string, set<string>> animals;
void initialize() {
animals["lion"] = {"mammal", "carnivore", "land", "four-legged"};
animals["eagle"] = {"bird", "flies", "carnivore", "feathers"};
animals["shark"] = {"fish", "swims", "carnivore", "fins"};
}
string identify(const set<string>& features) {
for (const auto& entry : animals) {
if (includes(features.begin(), features.end(),
entry.second.begin(), entry.second.end())) {
return entry.first;
}
}
return "unknown animal";
}
int main() {
initialize();
set<string> query = {"bird", "flies", "carnivore", "feathers"};
cout << "Identified animal: " << identify(query) << '\n';
return 0;
}