So I Need To Extract All The Words That Starts With A Vowel From A User Given Sentence And Print Them....
I can't build a code...(can't Think Anything about the code Algorithm)
Help Will Be Appreciated...
Thank You
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <iterator>
usingnamespace std;
const string vowels{ "aeiouAEIOU" };
int main()
{
istringstream in( "So I Need To Extract All The Words That Starts With A Vowel From A User Given Sentence And Print Them" );
copy_if( istream_iterator<string>{ in }, {}, ostream_iterator<string>{ cout, " " }, []( string s ){ return vowels.find( s[0] ) != string::npos; } );
}
or just
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <sstream>
#include <string>
usingnamespace std;
const string vowels{ "aeiouAEIOU" };
int main()
{
istringstream in( "So I Need To Extract All The Words That Starts With A Vowel From A User Given Sentence And Print Them" );
for ( string s; in >> s; ) if ( vowels.find( s[0] ) != string::npos ) cout << s << ' ';
}