-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path(7 kyu) Mumbling.cpp
42 lines (40 loc) · 1002 Bytes
/
(7 kyu) Mumbling.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
#include <string>
#include <cctype>
// #1
// class Accumul
// {
// public:
// static std::string accum(const std::string &s)
// {
// std::string res;
// for (int i = 0; i < s.length(); i++)
// {
// std::string word;
// for (int j = 0; j <= i; j++)
// if (j == 0)
// word += std::toupper(s[i]);
// else
// word += std::tolower(s[i]);
// res += word;
// if (i < s.length() - 1)
// res += "-";
// }
// return res;
// }
// };
// #2
class Accumul
{
public:
static std::string accum(const std::string &s)
{
std::string result;
for (int i = 0; i < s.length(); i++)
{
result.append("-");
result.append(std::string(1, toupper(s[i])));
result.append(std::string(i, tolower(s[i])));
}
return result.substr(1, result.length());
}
};