another kata
This commit is contained in:
18
Simple Fun 176 Reverse Letter/main.cpp
Normal file
18
Simple Fun 176 Reverse Letter/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
std::string reverse_letter(const std::string &str)
|
||||
{
|
||||
std::string alphabet ("abcdefghijklmnopqrstuvwxyz");
|
||||
std::string result ("");
|
||||
for (int i = str.length() - 1; i >= 0; i--){
|
||||
if (alphabet.find(str[i]) != std::string::npos){
|
||||
result.push_back(str[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(){
|
||||
std::cout << reverse_letter("Ba3rti1bo0y!");
|
||||
}
|
||||
Reference in New Issue
Block a user