Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int n,a[100];
- void citire()
- {
- int i;
- cout<<"n=";cin>>n;
- for(i=1;i<=n;i++)
- {
- cout<<"a["<<i<<"]=";
- cin>>a[i];
- }
- }
- int cmmdc (int a, int b)
- {
- int r;
- while(b!=0)
- {r=a%b;
- a=b;
- b=r;
- }
- return a;
- }
- int divide(int p,int q)
- {
- int m,c1,c2,c;
- if(p==q)
- c=a[p];
- else
- {
- m=(p+q)/2;
- c1=divide(p,m);
- c2=divide(m+1,q);
- c=cmmdc(c1,c2);
- return c;
- }
- }
- int main()
- {
- citire();
- cout<<divide(1,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement