Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <string>
  4. //#include <cmath>
  5. //#include <climits>
  6. //#include <algorithm>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.  
  12.     freopen("input.txt", "r", stdin);
  13.     freopen("output.txt", "w", stdout);
  14.  
  15.  
  16.     string s, temp_s;
  17.     getline(cin, s);
  18.     int length = s.length(), k = 0;
  19.     string *arr = new string[length];
  20.  
  21.     if (!isspace(s[length - 1]))
  22.         s += " ";
  23.  
  24.     for (char c : s) {
  25.  
  26.         if (isalpha(c) || isdigit(c)) {
  27.             c = tolower(c);
  28.             temp_s += c;
  29.         }
  30.  
  31.         if (isspace(c)) {
  32.             if (temp_s.length() > 3) {
  33.                 arr[k++] = temp_s;
  34.             }
  35.             temp_s = "";
  36.         }
  37.     }
  38.  
  39.     for (int i = 0; i < k; i++) {
  40.         if (i != k - 1)
  41.             cout << arr[i] << " ";
  42.         else
  43.             cout << arr[i];
  44.  
  45.     }
  46.  
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement