-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblemnumber20.cpp
More file actions
43 lines (35 loc) · 900 Bytes
/
problemnumber20.cpp
File metadata and controls
43 lines (35 loc) · 900 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
38
39
40
41
42
43
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include <string>
using namespace std;
//function work to capitalize the letters that occupy even indexes and odd indexes separately
pair<string, string> capitalize(string s)
{
string words1;
string words2;
for (int i = 0; i < s.length(); i++)
{
if (i % 2 == 0)
{
words1 += char(s[i] + 32);
words2 += s[i];
}
else
{
words2 += char(s[i] + 32);
words1 += s[i];
}
}
return { words1, words2 };
}
int main() {
capitalize("abcdef");
return 0;
}
/*Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index 0 will be considered even.
For example, capitalize("abcdef") = ['AbCdEf', 'aBcDeF']. See test cases for more examples.
The input will be a lowercase string with no spaces.
Good luck!
If you like this Kata, please try: */