mashlukashova

Untitled

May 20th, 2019
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. string str;
  8. int el_vec = 0;
  9. int kol = 0;
  10. vector<char>str_dop;
  11. int w = 0;
  12. cout << "vvedite str: " << endl;
  13. getline(cin, str);
  14. int n;
  15. n = str.length();
  16. string str_glas;
  17. int l;
  18. cout << "vvedite str_glas: " << endl;
  19. getline(cin, str_glas);
  20. l = str_glas.length();
  21. int v = 0;
  22.  
  23. for (int i = 0; i < n; i++){
  24. if (str[i] != '.')v++;
  25. if (str[i] == '.')break;
  26. }
  27.  
  28. for (int i = 0; i < v; i++){
  29. for (int j = 0; j < l; j++){
  30. if(str[0] == str_glas[j]){w++; break;}
  31.  
  32. }
  33. }
  34. if (w > 0){
  35. for (int i = 0; i < v; i++){
  36. if (str[i] != ' '){
  37. str_dop.push_back(str[i]);
  38. el_vec++;
  39. }
  40. if (str[i] == ' ')break;
  41. }
  42. str_dop.push_back(' ');
  43. el_vec++;
  44. }
  45. else cout << " 1 slovo nach ne s glas " << endl;
  46.  
  47. w = 0;
  48.  
  49. int k = 0;
  50.  
  51. for (int i = 1; i < v; i++){
  52. k++;
  53. if ((str[i - 1] == ' ') && (str[i] != ' ')){
  54. for (int j = 0; j < l; j++){
  55. if (str[i] == str_glas[j])w++;
  56. }
  57. }
  58.  
  59. if (w > 0){
  60. for (int j = k; j < v; j++){
  61. if (str[j] != ' '){
  62. str_dop.push_back(str[j]);
  63. el_vec++;
  64. }
  65. if (str[j] == ' '){
  66. str_dop.push_back(' ');
  67. el_vec++;
  68. break;}
  69. }
  70. w = 0;
  71. }
  72. if (w = 0)continue;
  73.  
  74. }
  75.  
  76. for (int i = 0; i < el_vec; i++){
  77. if (str_dop[i] == ' ')kol++;
  78. }
  79. cout << endl << "kol-vo slov nach s glas: " << kol + 1 << endl;
  80.  
  81. cout << endl;
  82. cout << "slova nach s glas: ";
  83. for (int i = 0; i < el_vec; i++){
  84. cout << str_dop[i];
  85. }
  86. cout << endl;
  87.  
  88. int b = 1;
  89. vector<char>str_dop2;
  90. int el_vec2 = 0;
  91. for (int i = 0; i < n; i++){
  92. if (str[i] == ' '){b++;
  93. if (b > 2){str_dop2.push_back(' ');
  94. el_vec2++;
  95. }
  96. }
  97. if (((b % 4) == 0) && (str[i] != ' ') && (str[i] != '.')){
  98. str_dop2.push_back(str[i]);
  99. el_vec2++;
  100. }
  101. }
  102. cout << endl;
  103. cout << "slova s kratnim 4 nomerom: ";
  104. for (int i = 0; i < el_vec2; i++){
  105. cout << str_dop2[i];
  106. }
  107. cout << endl;
  108.  
  109. return 0;
  110. }
RAW Paste Data