mashlukashova

Untitled

May 21st, 2019
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main(){
  6. string str;
  7. cout << "vvedite text: " << endl;
  8. getline(cin, str);
  9. int n;
  10. n = str.length();
  11. int v = 1;
  12.  
  13.  
  14. for (int i = 0; i < n; i++){
  15. if (str[i] == ' ')v++;
  16. }
  17.  
  18. int k = 0;
  19. int l = 0;
  20. int z = 0;
  21. for (int i = 0; i < n; i++){
  22. if (str[i] == ' ')k++;
  23. if (k == v -1){
  24. for (int j = i + 1; j < n; j++){
  25. l++;
  26. if (((int)str[j] >= 48) && ((int)str[j] <= 57)){
  27. z++;
  28. }
  29. }
  30. break;
  31. }
  32. }
  33. cout << "z= " << z << endl;
  34.  
  35.  
  36. char p;
  37. cout << "nazhmite lub klavishu: " << endl;
  38. cin >> p;
  39. if (p != '%'){
  40.  
  41.  
  42.  
  43. int b = 0;
  44. int a = 0;
  45. int c = 0;
  46. for (int i = 0; i < n; i++){
  47. if (str[i] != ' ')b++;
  48. if ((str[i] == ' ') || (str[i] == '.')){
  49. for (int j = a; j < b; j++){
  50. if (((int)str[j] >= 48) && ((int)str[j] <= 57)){
  51. c++; }
  52.  
  53. }
  54. if (c <= z){
  55. for (int j = a; j < b; j++){
  56. cout << str[j];
  57. }
  58. }
  59. if (c > z){
  60. cout << " " << "{";
  61. for (int j = a; j < b; j++){
  62. cout << str[j];
  63. }
  64. cout << "}" << " ";
  65. }
  66. c = 0;
  67. a = b;
  68. b++;
  69. }
  70.  
  71. }
  72.  
  73. cout << endl;
  74.  
  75.  
  76. }
  77.  
  78.  
  79. return 0;
  80. }
RAW Paste Data