Advertisement
myLoveOnlyForYou

Untitled

Mar 4th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. while (getline(cin, str)) {
  2. string answer = "";
  3. int word_length = 0;
  4. for (char& a : str) {
  5. if ((a >= 'a' && a <= 'z') || (a == ' ') || (a >= 'A' && a <= 'Z') || (a >= '0' && a <= '9')) {
  6. if (a != ' ')
  7. word_length++;
  8. if (a >= 'A' && a <= 'Z') {
  9. char ch((int)a + 32);
  10. answer += ch;
  11. }
  12. else
  13. answer += a;
  14. }
  15. if (a == ' ') {
  16. // cout << answer << " " << word_length << endl;
  17. if (word_length <= 3) {
  18. for (int j = 0; j <= word_length; j++)
  19. answer.pop_back();
  20. }
  21. word_length = 0;
  22. }
  23. }
  24. if (word_length <= 3 && word_length > 0)
  25. for (int i = 0; i < word_length; i++)
  26. answer.pop_back();
  27. if (counter == 0)
  28. first_answer = answer;
  29. else
  30. second_answer = answer;
  31. counter++;
  32. cout << answer << endl;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement