Advertisement
Pafnytiu

рекурсия 3 -17 сдать

Jun 14th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include<string>
  2. #include<iostream>
  3. using namespace std;
  4. int Func(string s)
  5. {
  6. if (isupper(s[0]))
  7. return 0;
  8.  
  9. for (int i = 1; i < s.length(); i++)
  10. {
  11. if (isupper(s[i]) && (ispunct(s[i - 1]) || s[i - 1] == ' '))
  12. return i;
  13. }
  14. return -1;
  15. }
  16. void Func_Rec(string &s)
  17. {
  18. int i = Func(s);
  19.  
  20. if (i == -1)
  21. return;
  22. else
  23. {
  24. int k = i;
  25. while (!(ispunct(s[k]) || s[k] == ' '))
  26. k++;
  27. k -= i;
  28. s.replace(i, k, "...");
  29. Func_Rec(s);
  30. }
  31. }
  32. int main()
  33. {
  34. setlocale(0, "");
  35. string s;
  36. cout << "Введите строку" << endl;
  37. getline(cin, s);
  38. Func_Rec(s);
  39. cout << s << endl;
  40. system("pause");
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement