Advertisement
aimon1337

numere negative

Jan 29th, 2020
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int nr=0;
  4. int v[250];
  5. int deti(int li, int ls)
  6. {
  7.     if(li==ls)
  8.         {
  9.             if(v[li]<0)
  10.                 nr++;
  11.             return nr;
  12.         }
  13.     else
  14.     {
  15.         int mij,s1,s2;
  16.         mij=(li+ls)/2;
  17.         s1=deti(li,mij);
  18.         s2=deti(mij+1,ls);
  19.         return s1+s2;
  20.     }
  21. }
  22.  
  23. int main()
  24. {
  25.     int n;
  26.     cin>>n;
  27.     for(int i=1;i<=n;++i)
  28.         cin>>v[i];
  29.     if(deti(1,n)%2==0)
  30.         cout<<"DA";
  31.         else
  32.             cout<<"NU";
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement