Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char line[127];
  9.  
  10. cout << "Vvedite stroky, sostoyaschyy iz 0, 1 i probelov: " << endl;
  11. gets_s(line);
  12.  
  13. int len = strlen(line),
  14. fives = 0,
  15. count = 0,
  16. max = 0,
  17. min = 100,
  18. n = 0,
  19. count2 = 0;
  20.  
  21.  
  22. for (int i = 0; i <= len; i++)
  23. {
  24. if (line[i] == '0' || line[i] == '1')
  25. {
  26. count++;
  27. count2++;
  28. }
  29. else
  30. if (line[i] == ' ' || line[i] == '\0')
  31. {
  32. if (count2 > max)
  33. {
  34. max = count2;
  35. }
  36. else if (count2 < max)
  37. {
  38. if (count2 < min)
  39. {
  40. if(count2 != 0)
  41. min = count2;
  42. }
  43. }
  44. if (count == 5)
  45. {
  46. fives++;
  47. }
  48. count = 0;
  49. count2 = 0;
  50. continue;
  51. }
  52. else
  53. {
  54. cout << "error" << endl;
  55. break;
  56. }
  57. }
  58.  
  59. for (int i = 0, count = 0; i <= len; i++)
  60. {
  61. if (line[i] == '0' || line[i] == '1')
  62. {
  63. count++;
  64. }
  65. else
  66. if (line[i] == ' ' || line[i] == '\0')
  67. {
  68. if (count == max)
  69. {
  70. cout << "Max: ";
  71. for (n = 0; n < max; n++)
  72. {
  73. cout << line[i - max + n];
  74. }
  75. cout << endl;
  76. }
  77. if (count == min)
  78. {
  79. cout << "Min: ";
  80. for (n = 0; n < min; n++)
  81. {
  82. cout << line[i - min + n];
  83. }
  84. cout << endl;
  85. }
  86. count = 0;
  87. continue;
  88. }
  89. }
  90.  
  91.  
  92. cout << endl << fives << endl;
  93.  
  94. return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement