-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfile_operator.cpp
More file actions
51 lines (44 loc) · 1.19 KB
/
file_operator.cpp
File metadata and controls
51 lines (44 loc) · 1.19 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
51
#include <iostream>
#include <vector>
#include <sstream>
void lprint(std::vector<std::string> &words);
void read2pipe() {
// std::in
std::string line;
while(std::getline(std::cin, line)) {
std::istringstream s(line);
std::string word;
std::vector<std::string> words;
while(s >> word) {
std::string::iterator siter = word.begin();
bool english = true;
for(; siter != word.end(); siter++) {
if (*siter >= 'a' and *siter <= 'z') {
}
else if (*siter >= 'A' and *siter <= 'Z') {
}
else {
english = false;
}
}
if (english) {
words.push_back(word);
}
}
if (words.size() == 2) {
lprint(words);
}
words.clear();
}
}
void lprint(std::vector<std::string> &words) {
for (std::vector<std::string>::iterator iter = words.begin();
iter != words.end(); iter++) {
std::cout << (*iter) << "\t";
}
std::cout << std::endl;
}
int main() {
read2pipe();
return 0;
}