Advertisement
rotti321

Dist max platouri

Feb 24th, 2022
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. /*
  2. Afisati cea mai mare distanta dintre doua platouri
  3. de lungime maxima
  4.   */
  5.  
  6. #include <bits/stdc++.h>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.     ifstream cin("test.in");
  12.     ofstream cout("test.out");
  13.     int x,y,s=1,lung=1,lmax=0,vmin=9999999,prim,ultim,poz=1,dis,dmax,sf;
  14.   cin>>x;
  15.   while(cin>>y){
  16.     poz++;///pozitia curenta
  17.  //   cout<<x<<" "<<y<<endl;
  18.     if(x!=y){
  19.       s++;
  20.       lung=1;
  21.     }
  22.     else{ ///x==y
  23.       lung++;
  24.       if(lung>lmax){
  25.         dmax=0;
  26.         lmax=lung;
  27.         vmin=y;
  28.         prim=y;
  29.         ultim=y;
  30.       }
  31.       else if(lung==lmax){
  32.         ultim=y;
  33.           if(vmin>y){
  34.             vmin=y;
  35.           }  
  36.         }
  37.     }
  38.     x=y;
  39.   }
  40.  
  41.   cout<<lmax<<" "<<vmin<<endl<<prim<<" "<<ultim;
  42.  
  43.  
  44.     return 0;
  45. }
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement