Skip to content

Commit 11d9b95

Browse files
authored
Update main.cpp
1 parent b644b43 commit 11d9b95

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

main.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,27 @@ char* flip5(char *input) {
6464
return input;
6565
}
6666

67+
void flip6(string input) {
68+
for(int index=input.length()-1; index>=0; index--)
69+
cout << input[index];
70+
}
71+
72+
char* flip7(char const* input) {
73+
int length = strlen(input);
74+
char *temp = new char[length+1];
75+
strcpy(temp, input);
76+
for(int index=0, counter=length-1; index<counter; index++,counter--)
77+
swap(temp[index], temp[counter]);
78+
return temp;
79+
}
80+
81+
void flip8(string &input)
82+
{
83+
int length = input.length();
84+
for(int index = 0; index < length/2; index++)
85+
std::swap(input[index], input[length-index-1]);
86+
}
87+
6788
void check(string input) {
6889
const unsigned int size=input.length();
6990
const unsigned int middle=size / 2;

0 commit comments

Comments
 (0)