Advertisement
ValerianBenchea

+++2lap 20 de puncte

Feb 20th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ifstream fin("2lap.in");
  6. ofstream fout("2lap.out");
  7. int v[101];
  8. int main()
  9. {
  10.     int N, M, i=1, cnt=1, produs=1, K1, K2, K=0;
  11.     fin>>N;
  12.     fin>>M;
  13.     while(fin>>v[cnt])
  14.     {
  15.         cnt++;
  16.     }
  17.     for(int i=0; i<cnt-1; i++)
  18.     {
  19.         for(int j=i+1; j<cnt; j++)
  20.         {
  21.             if(v[i]>v[j])
  22.             {
  23.                 swap(v[i], v[j]);
  24.             }
  25.         }
  26.     }
  27.     K1=v[N];
  28.     K2=v[M];
  29.     fout<<K1<<" "<<K2<<"\n";
  30.  
  31.     for(i=N+1; i<M; i++)
  32.     {
  33.         produs=produs*v[i];
  34.     }
  35.     while(produs%2==0)
  36.     {
  37.         produs=produs/2;
  38.         K++;
  39.     }
  40.     fout<<K<<"\n";
  41.     for(i=N+1; i<M; i++)
  42.         fout<<v[i]<<" ";
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement