Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int v[100],n;
  4. int estePrim(int a)
  5. {
  6.         int contor=0;
  7.     for (int i=1; i<=a; i++)
  8.     {
  9.         if (a%i==0)
  10.             contor++;
  11.     }
  12.     if (contor==2)
  13.         return a;
  14.     else
  15.         return 0;
  16. }
  17. int divide(int i,int j)
  18. {
  19.     int a,b;
  20.     if(i==j)
  21.         return v[i];
  22.     else
  23.     {
  24.         a=divide(i,(i+j)/2);
  25.         b=divide((i+j)/2+1,j);
  26.              if(estePrim(a)>estePrim(b))
  27.                return a;
  28.             else
  29.             {
  30.                 return b;
  31.             }
  32.     }
  33. }
  34. int main()
  35. {
  36.     cin>>n;
  37.     for(int i=0;i<n;i++)
  38.     {
  39.         cin>>v[i];
  40.     }
  41.     cout<<divide(0,n-1);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement