Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- char line[127];
- cout << "Vvedite stroky, sostoyaschyy iz 0, 1 i probelov: " << endl;
- gets_s(line);
- int len = strlen(line),
- fives = 0,
- count = 0,
- max = 0,
- min = 100,
- n = 0,
- count2 = 0;
- for (int i = 0; i <= len; i++)
- {
- if (line[i] == '0' || line[i] == '1')
- {
- count++;
- count2++;
- }
- else
- if (line[i] == ' ' || line[i] == '\0')
- {
- if (count2 > max)
- {
- max = count2;
- }
- else if (count2 < max)
- {
- if (count2 < min)
- {
- if(count2 != 0)
- min = count2;
- }
- }
- if (count == 5)
- {
- fives++;
- }
- count = 0;
- count2 = 0;
- continue;
- }
- else
- {
- cout << "error" << endl;
- break;
- }
- }
- for (int i = 0, count = 0; i <= len; i++)
- {
- if (line[i] == '0' || line[i] == '1')
- {
- count++;
- }
- else
- if (line[i] == ' ' || line[i] == '\0')
- {
- if (count == max)
- {
- cout << "Max: ";
- for (n = 0; n < max; n++)
- {
- cout << line[i - max + n];
- }
- cout << endl;
- }
- if (count == min)
- {
- cout << "Min: ";
- for (n = 0; n < min; n++)
- {
- cout << line[i - min + n];
- }
- cout << endl;
- }
- count = 0;
- continue;
- }
- }
- cout << endl << fives << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement