Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("Citire.in");
  5.  
  6.  
  7. int t[100];
  8.  
  9. int cmmdc(int a , int b)
  10. {
  11. while (a!=b)
  12. if(a>b)
  13. a-=b;
  14. else
  15. b-=a;
  16. return a;
  17. }
  18. int cmmdcelemente(int s,int d)
  19. {
  20. if(s==d)
  21. return t[s];
  22. else
  23. {
  24. int m=(s+d)/2;
  25. return cmmdc(cmmdcelemente(s,m),cmmdcelemente(m+1,d));
  26. }
  27. }
  28. void Citire(t[],&n)
  29. {
  30. fin>>n;
  31. for(int i=0;i<n;i++)
  32. fin>>t[i];
  33. }
  34.  
  35. void AfisareVector(t[],n);
  36. {
  37. cout<<"Elementele sunt : ";
  38. for(int i=0;i<n;i++)
  39. cout<<t[i]<<" ";
  40. cout<</n;
  41. }
  42.  
  43. int main(void)
  44. {
  45. CitireVector(t,n);
  46. AfisareVector(t,n);
  47. cout<<"CMMDC ="<<cmmdcelemente(s,m-1);
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement