Guest User

Untitled

a guest
Feb 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. int main()
  2. {
  3. setlocale(LC_ALL, "Russian");
  4. int n;
  5. cout << "введите число элементов" << endl;
  6. cin >> n;
  7. cin.clear();
  8. char *a = new char[n+1];
  9. int L = 0;
  10. char cBuffer;
  11. int iBuffer;
  12. int count = 0;
  13. int counter = 0;
  14. int nomerMax = 0;
  15. gets_s(a, n+1);
  16. cin.getline(a, n+1);
  17. int stroka = 0;
  18. for (int i = 0; i < strlen(a); i++)
  19. {
  20. while (a[i] == 48 || a[i] == 49 || a[i] == 50 || a[i] == 51 || a[i] == 52 || a[i] == 53 || a[i] == 54 || a[i] == 55 || a[i] == 56 || a[i] == 57)
  21. i++;
  22. L = i;
  23. while (!((a[i] == 48) || (a[i] == 49) || (a[i] == 50) || (a[i] == 51) || (a[i] == 52) || (a[i] == 53) || (a[i] == 54) || (a[i] == 55) || (a[i] == 56) || (a[i] == 57)))
  24. {
  25. if (i == strlen(a))
  26. break;
  27. i++;
  28. }
  29.  
  30. if (L < i)
  31. stroka++;
  32. }
  33. cout << "строк разбито: " << stroka << endl;
  34. char **massivPodstrok = new char*[stroka];
  35. int markerStrok = 0;
  36. int maxSize = 0;
  37. for (int i = 0; i < strlen(a); i++)
  38. {
  39. while (a[i] == 48 || a[i] == 49 || a[i] == 50 || a[i] == 51 || a[i] == 52 || a[i] == 53 || a[i] == 54 || a[i] == 55 || a[i] == 56 || a[i] == 57)
  40. i++;
  41. L = i;
  42. while (!((a[i] == 48) || (a[i] == 49) || (a[i] == 50) || (a[i] == 51) || (a[i] == 52) || (a[i] == 53) || (a[i] == 54) || (a[i] == 55) || (a[i] == 56) || (a[i] == 57)))
  43. {
  44. if (i == strlen(a))
  45. break;
  46. i++;
  47. }
  48. int h = 0;
  49.  
  50. for (int I = L; I < i; I++)
  51. {
  52. h++;
  53.  
  54. if (maxSize < h)
  55. {
  56. maxSize = h;
  57. nomerMax = count;
  58. }
  59.  
  60. }
  61.  
  62. massivPodstrok[count] = new char[h];
  63. count++;
  64.  
  65. }
  66. cout << "максимальная длина строки " << maxSize << endl;
  67. cout << "номер строки максимальной длины: " << nomerMax +1 << endl;
  68.  
  69. count = 0;
  70. for (int i = 0; i < strlen(a)+1; i++)
  71. {
  72. while (a[i] == 48 || a[i] == 49 || a[i] == 50 || a[i] == 51 || a[i] == 52 || a[i] == 53 || a[i] == 54 || a[i] == 55 || a[i] == 56 || a[i] == 57)
  73. i++;
  74. L = i;
  75. while (!((a[i] == 48) || (a[i] == 49) || (a[i] == 50) || (a[i] == 51) || (a[i] == 52) || (a[i] == 53) || (a[i] == 54) || (a[i] == 55) || (a[i] == 56) || (a[i] == 57)))
  76. {
  77. if (i == strlen(a))
  78. break;
  79. i++;
  80. }
  81. int h = 0;
  82.  
  83. for (int I = L; I < i; I++)
  84. {
  85. iBuffer = a[I];
  86. cBuffer = (char)iBuffer;
  87. if (count < stroka)
  88. {
  89. massivPodstrok[count][h] = cBuffer;
  90. cout << massivPodstrok[count][h];
  91. }
  92. h++;
  93. }
  94.  
  95. cout << endl;
  96. count++;
  97.  
  98. }
  99. cout << count;
  100. for (int i = 0; i < stroka; i++)
  101. delete massivPodstrok[i];
  102. delete[] massivPodstrok;
  103. delete[] a;
  104.  
  105. _getch();
  106. return 0;
  107. }`
  108.  
  109. delete[] massivPodstrok[i]
  110.  
  111. massivPodstrok[count] = new char[h];
  112.  
  113. while (a[i] == 48 || a[i] == 49 || a[i] == 50 || a[i] == 51 || a[i] == 52 || a[i] == 53 || a[i] == 54 || a[i] == 55 || a[i] == 56 || a[i] == 57)
  114. i++;
  115.  
  116. if(a[i] == 48 || a[i] == 49 || a[i] == 50 || a[i] == 51 || a[i] == 52 || a[i] == 53 || a[i] == 54 || a[i] == 55 || a[i] == 56 || a[i] == 57)
  117. continue;
  118.  
  119. #include <cctype>
  120. // ...
  121.  
  122. if(std::isdigit(a[i]))
  123.  
  124. for (int i = 0, len = strlen(a); i < len; i++)
  125. {
  126. if(std::isdigit(a[i])) continue;
  127. L = i;
  128. while (!std::isdigit(a[i]))
  129. {
  130. if (i == len)
  131. break;
  132. i++;
  133. }
  134.  
  135. if (L < i)
  136. stroka++;
  137. }
  138.  
  139. cin >> n;
Add Comment
Please, Sign In to add comment