Advertisement
Norbysweg

div1

Jun 1st, 2021
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void beolvas(int a[],int &n,int &x)
  6. {
  7.     cin>>n;
  8.     for (int i=1;i<=n;i++)
  9.         cin>>a[i];
  10.     cin>>x;
  11. }
  12.  
  13. bool divide_et_impera(int a[],int e,int v,int x)
  14. {
  15.     if (e==v)
  16.         return a[e]==x;
  17.     int kozep=(e+v)/2;
  18.     bool f1=divide_et_impera(a,e,kozep,x);
  19.     bool f2=divide_et_impera(a,kozep+1,v,x);
  20.     if (f1||f2)
  21.         return 1;
  22.     else
  23.         return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement