-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimonsays.cpp
54 lines (43 loc) · 912 Bytes
/
simonsays.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
51
52
53
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
int main() {
int n;
cin >> n;
while (n-- > 0) {
// Read entire line into a string
string s;
while (s.empty()) {
getline(cin, s);
}
// Tokenize by space.
string buf;
stringstream ss(s);
vector<string> tokens;
while (ss >> buf) {
tokens.push_back((buf));
}
// Check first and second token, then print.
if (tokens.at(0) == "Simon" && tokens.at(1) == "says") {
for (int i = 2; i < tokens.size(); ++i) {
cout << tokens.at(i) << " ";
}
}
}
return 0;
}
/*
//It's that time again. Kattis does not have string.starts_with......
int main() {
string start = "Simon says";
int n;
cin >> n;
while (n-- >= 0) {
if (s.starts_with(start)) {
cout << s.substr(start.length() + 1) << "\n";
}
}
return 0;
}
*/