-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.cpp
More file actions
47 lines (35 loc) · 1.03 KB
/
clean.cpp
File metadata and controls
47 lines (35 loc) · 1.03 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
//No Explaination
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string str = "Hello World";
cout << "Original: " << str << endl;
cout << "Origin String Length: " << str.length() << endl;
cout << "Single Char: " << str[1] << endl;
string sub = str.substr(6, 5);
cout << "Substring: " << sub << endl;
string added_word = str;
added_word.insert(5, " Beautiful");
cout << "Insert: " << added_word << endl;
string rep = str;
rep.replace(6, 5, "Universe");
cout << "Replace: " << rep << endl;
string del = str;
del.erase(5, 6);
cout << "Erased: " << del << endl;
string append_word= str;
append_word.append(" HAHA");
cout << "Append: " << append_word << endl;
string rev = str;
reverse(rev.begin(), rev.end());
cout << "Reverse: " << rev << endl;
string caps = str;
transform(caps.begin(), caps.end(), caps.begin(), ::toupper);
cout << "CAPS: " << caps << endl;
string lower = caps;
transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
cout << "Lower: " << lower << endl;
return 0;
}