Advertisement
rotti321

BAC 2017 iunie III Ex. 4

Mar 16th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int x,y,lung=0,lmax=0,k=0;
  9.     ifstream fin("bac.txt");
  10.     fin>>x;
  11.     if(x%2==0){ ///daca am pe prima poz par
  12.         lung=1;
  13.     }
  14.     while(fin>>y){
  15.         if(x%2==0 && y%2==0){
  16.             lung++;
  17.         }
  18.         if(x%2==0 && y%2!=0){
  19.             if(lmax<lung){
  20.                 lmax=lung;
  21.                 k=1;
  22.             }
  23.             else
  24.             if(lung==lmax){
  25.                 k++;
  26.             }
  27.         }
  28.         if(x%2!=0 && y%2==0){
  29.             lung=1;
  30.         }
  31.         x=y;
  32.     }
  33.     if(lung>lmax){
  34.         k=1;
  35.     }
  36.     else
  37.     if(lung==lmax){
  38.         k++;
  39.     }
  40.     cout<<k;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement