Advertisement
Eddie_1337

bac 2017 sub 3 ex 4

Sep 14th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main () {
  7.     int v[1000001], x = 0, c = 0, i = 1, max = 0, j;
  8.     ifstream f("bac.txt");
  9.     while(f >> v[i]) {
  10.         if(v[i] % 2 == 0)
  11.             c++;
  12.         else {
  13.             if(max < c)
  14.                 max = c;
  15.             c = 0;
  16.         }
  17.         i++;
  18.     }
  19.     f.close();
  20.     c = 0;
  21.     for(j = 1; j < i; j++) {
  22.         if(v[j] % 2 == 0)
  23.             c++;
  24.         else
  25.             c = 0;
  26.         if(max == c)
  27.             x++;
  28.     }
  29.     cout << x;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement