Advertisement
icatalin

algoritm 2.10.2015

Oct 2nd, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int v[1000],n;
  6.  
  7. int elemimp(int s,int d,int &ok)
  8. {
  9.     if (s==d)
  10.     {
  11.         if (v[s]%2==0)
  12.             ok=1;
  13.         return;
  14.     }
  15.     else
  16.     {
  17.         int mij=(s+d)/2;
  18.         elemimp(s,mij,ok);
  19.         elemimp(mij+1,d,ok);
  20.     }
  21.    
  22. }
  23.  
  24.  
  25.  
  26.  
  27. int main()
  28. {
  29.     int i,ok;
  30.     cin>>n;
  31.     for (i=1;i<=n;i++)
  32.         cin>>v[i];
  33.  
  34.     cout<<elemimp(1,n,ok);
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement