Mam pierwszy napis, który zawiera jakieś słowo. Z tego słowa muszę wypisać tylko samogłoski.
Mam drugi napis, który zawiera jakieś słowo. Z tego słowa muszę wypisać same spółgłoski.
Mam połączyć te napisy - jak mam to zrobić, skoro one są w różnych pętlach? Jak powinna wyglądać trzecia pętla, która je połączy?
0
1
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
class isVovel {
private:
const string vovels {"aeiou"};
public:
bool operator()(const char& c) const;
typedef char argument_type;
};
bool isVovel::operator ()(const char& c) const {
return (vovels.find(c) != std::string::npos);
}
int main() {
std::string s1 = "This is first sample string!";
std::string s2 = "This strings has vovels!";
auto it1 = std::remove_if(s1.begin(), s1.end(), isVovel());
auto it2 = std::remove_if(s2.begin(), s2.end(), std::not1(isVovel()) );
std::string result = std::string(s1.begin(), it1) + std::string(s2.begin(), it2);
std::cout << "Result: " << result << std::endl;
return 0;
}