Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<vector>
- using namespace std;
- typedef vector < string > strvec;
- strvec get_all_words(string text){
- strvec result;
- string temp;
- for (int i = 0; i < text.size(); ++i){
- if (isalnum(text[i])){
- temp += text[i];
- } else {
- if (!temp.empty()){
- result.push_back(temp);
- temp.clear();
- }
- }
- }
- return result;
- }
- bool good(char ch){
- ch = tolower(ch);
- return ch == 'e' || ch == 'u' || ch == 'i' || ch == 'o' || ch == 'a' || ch == 'y';
- }
- bool check(const string &word){
- return good(*word.rbegin());
- }
- bool isnum(const string &word){
- for (int i = 0; i < word.size(); ++i){
- if (isalpha(word[i])){
- return false;
- }
- }
- return true;
- }
- int main(){
- ifstream in("input.txt");
- ofstream out("output.txt");
- string all;
- string line;
- while (getline(in, line)){
- all += line + "\n";
- out << line << "\n";
- }
- strvec words = get_all_words(all),
- small_words;
- int cnt = 0;
- for (int i = 0; i < words.size();){
- cnt += check(words[i]);
- if (words[i].size() < 5){
- small_words.push_back(words[i]);
- }
- if (!isnum(words[i])){
- words.erase(words.begin() + i);
- } else {
- ++i;
- }
- }
- cout << cnt << "\n"
- << "Numbers:\n";
- for (int i = 0; i < words.size(); ++i){
- cout << words[i] << " ";
- }
- cout << "\n"
- << "Small words:\n";
- for (int i = 0; i < small_words.size(); ++i){
- cout << small_words[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement