:)) no man, i want to have 2 files, one with vowels, one without. I don't know how to do this.
This is a string. ----> string a is This. I want 2nd file to be without vowels and backwards.
Its not best solution but its better then nothing:
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 48 49 50 51 52 53 54 55
|
#include <iostream>
#include <vector>
#include <string>
int main()
{
const std::string vowel = "aeiou";
std::string str = "This is a test.";
std::string result;
for(unsigned int i = 0; i < str.size(); ++i)
{
bool notVowel = true;
for(unsigned int j = 0; j < vowel.size(); ++j)
{
if(str[i] == vowel[j])
{
notVowel = false;
}
}
if(notVowel)
{
result += str[i];
}
}
std::cout << result << std::endl;
std::vector<std::string> v;
while(1)
{
std::string temp;
unsigned int pos = result.find_first_of(' ');
if(-1 == pos)
{
temp = result.substr(0, pos);
v.push_back(temp);
break;
}
temp = result.substr(0, pos);
v.push_back(temp);
result.erase(0, pos + 1);
}
std::vector<std::string>::reverse_iterator rb(v.begin());
std::vector<std::string>::reverse_iterator re(v.end());
while(re < rb)
{
std::cout << *re++ << " ";
}
std::cout << std::endl;
std::cout << "Press enter to exit...";
std::cin.get();
return 0;
}
| |
It prints string without vowels and backwards. You have to provide in/out from file.
Last edited on