Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int n,a[100];
  5. void citire()
  6. {
  7. int i;
  8. cout<<"n=";cin>>n;
  9. for(i=1;i<=n;i++)
  10. {
  11. cout<<"a["<<i<<"]=";
  12. cin>>a[i];
  13.  
  14. }
  15. }
  16. int cmmdc (int a, int b)
  17. {
  18. int r;
  19. while(b!=0)
  20. {r=a%b;
  21. a=b;
  22. b=r;
  23.  
  24. }
  25. return a;
  26. }
  27. int divide(int p,int q)
  28. {
  29. int m,c1,c2,c;
  30. if(p==q)
  31. c=a[p];
  32. else
  33. {
  34. m=(p+q)/2;
  35. c1=divide(p,m);
  36. c2=divide(m+1,q);
  37.  
  38. c=cmmdc(c1,c2);
  39. return c;
  40. }
  41.  
  42.  
  43. }
  44. int main()
  45. {
  46. citire();
  47. cout<<divide(1,n);
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement