-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe11.cpp
49 lines (39 loc) · 734 Bytes
/
e11.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
//
// Created by martin on 19/01/2022.
//
#include "../std_lib.h"
using namespace std;
vector<string> split (const string &s, const string &whitespaces)
{
vector<string> vs;
string s_copy = s;
for (char w : whitespaces)
{
for (char &c : s_copy)
{
if (c == w)
{
c = ' ';
}
}
}
istringstream iss {s_copy};
for (string word ; iss >> word ;)
{
vs.push_back(word);
}
return vs;
}
int main ()
{
string whitespaces {":|+"};
string line {"der:var|en gang+en mand."};
vector<string> vs = split(line, whitespaces);
cout << setw(10) << left << "input:" << line << endl;
cout << setw(10) << left << "output:";
for (auto &s : vs)
{
cout << s << " ";
}
cout << endl;
}