Advertisement
icatalin

cmmc vector

Apr 3rd, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n,m,r,v[100],a,b,i;
  8.     cout<<"n= ";cin>>n;
  9.     for (i=1;i<=n;i++)
  10.     cin>>v[i];
  11.     m=v[1];
  12.     for (i=2;i<=n;i++)
  13.     {
  14.         a=m;
  15.         b=v[i];
  16.         r=a%b;
  17.         while (r)
  18.         {
  19.             a=b;
  20.             b=r;
  21.             r=a%b;
  22.         }
  23.         m=(m*v[i])/b;
  24.     }
  25.     cout<<m;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement