Advertisement
ProgNeo

Untitled

Dec 5th, 2021
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main() {
  5. setlocale(LC_ALL, "rus");
  6.  
  7. bool wasNumber = false;
  8. string line;
  9. string words[200];
  10. cout << "Введите строку: ";
  11. getline(cin, line);
  12.  
  13. line += " ";
  14. size_t pos = 0;
  15. int count = 0;
  16. while ((pos = line.find(" ")) != string::npos)
  17. {
  18. words[count] = line.substr(0, pos);
  19. count++;
  20. line.erase(0, pos + 1);
  21. }
  22.  
  23. for (string& word : words)
  24. {
  25. if (word == "")
  26. {
  27. break;
  28. }
  29. if (wasNumber == false && word.find_first_not_of("1234567890-") == string::npos)
  30. {
  31. wasNumber = true;
  32. long long number = stoll(word);
  33. cout << "Числовое слово в кубе: " << number * number * number << endl;
  34. }
  35. if (word.length() == 4)
  36. {
  37. for (char& ch : word)
  38. {
  39. if (ch == 'A')
  40. {
  41. ch = 'O';
  42. }
  43. }
  44. cout << word << " ";
  45. }
  46. }
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement