-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatalogo.cpp
More file actions
50 lines (39 loc) · 1.07 KB
/
catalogo.cpp
File metadata and controls
50 lines (39 loc) · 1.07 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
42
43
44
45
46
47
48
49
50
/*#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<long long int>> libri (2, vector<long long int> (0));
void aggiungi (long long int id) {
if (find (libri[0].begin(), libri[0].end(), id) == libri[0].end()) {
libri[0].push_back(id);
libri[1].push_back(1);
} else {
int p = find (libri[0].begin(), libri[0].end(), id) - libri[0].begin();
libri[1][p] ++;
}
}
void togli (long long int id) {
int p = find (libri[0].begin(), libri[0].end(), id) - libri[0].begin();
libri[1][p] --;
}
int conta (long long int id) {
vector<long long int>::iterator p = find (libri[0].begin(), libri[0].end(), id);
if (p != libri[0].end()) {
return libri[1][p-libri[0].begin()];
} else {
return 0;
}
}*/
#include <iostream>
#include <map>
using namespace std;
std::map<string, int> book;
void aggiungi(long long int id) {
book[to_string(id)] ++;
}
void togli(long long int id) {
book[to_string(id)] --;
}
int conta(long long int id) {
return book[to_string(id)];
}