-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday05.cpp
More file actions
34 lines (29 loc) 路 864 Bytes
/
Copy pathday05.cpp
File metadata and controls
34 lines (29 loc) 路 864 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
int main() {
long count = 0;
std::vector<std::string> lowerRanges;
std::vector<std::string> upperRanges;
std::ifstream file("input.txt");
std::string str1;
while (std::getline(file, str1) && !str1.empty())
{
std::string delimiter = "-";
std::string str0 = str1.substr(0, str1.find(delimiter));
str1.erase(0, str1.find(delimiter) + delimiter.length());
lowerRanges.push_back(str0);
upperRanges.push_back(str1);
}
while (std::getline(file, str1))
{
for (int i = 0; i < lowerRanges.size(); ++i) {
if (stol(lowerRanges[i]) < stol(str1) && stol(str1) < stol(upperRanges[i])) {
count++;
break;
}
}
}
std::cout << count << std::endl;
return 0;
}