-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar2.cpp
50 lines (48 loc) · 1.11 KB
/
star2.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
#include <bits/stdc++.h>
// A quick way to split strings separated via any character
// delimiter.
std::vector<std::string> adv_tokenizer(std::string s, char del)
{
std::vector<std::string> ret;
std::stringstream ss(s);
std::string word;
while (!ss.eof()) {
getline(ss, word, del);
ret.push_back(word);
}
return ret;
}
std::stringstream split(std::string str){
std::string temp = "";
std::stringstream ret;
for(int i=0; i<(int)str.size(); i++){
if(str[i] != ',' && str[i] != '-'){
temp += str[i];
continue;
}
ret << temp;
temp = " ";
}
ret<<temp;
return ret;
}
int main(int argc, char const* argv[])
{
std::string inp;
int sum{0};
while(std::cin>>inp){
std::stringstream ss = split(inp + " ");
int e1p,e1e,e2p,e2e;
ss >> e1p >> e1e >> e2p >> e2e;
if(
e1e>=e2p && e1e<=e2e ||
e2e>=e1p && e2e<=e1e ||
e1p>=e2p && e1p<=e2e ||
e2p>=e1p && e2p<=e1e
){
sum++;
}
}
std::cout<<sum;
return 0;
}