-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTR02.cpp
More file actions
37 lines (36 loc) · 699 Bytes
/
Copy pathSTR02.cpp
File metadata and controls
37 lines (36 loc) · 699 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
35
36
37
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string proc(string n)
{
string result = "";
string pre = "";
const string valid = " abcdefghijklmnopqrstuvwxyz";
transform(n.begin(), n.end(), n.begin(), ::tolower);
for (auto c: n)
{
if (valid.find(c) != string::npos)
{
if (pre == " " || result == "")
{
c = toupper(c);
}
result += c;
pre = c;
}
}
return result;
}
int main()
{
int n;
string s;
cin >> n;
cin.ignore();
for (int i=0; i<=n; i++)
{
getline(cin, s);
cout << proc(s) << endl;
}
}