Advertisement
Dani_info

cmmdc a n nr var3

Dec 8th, 2017
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n,a,b,cmmdc,r,i;
  8.     cout<<"Introduceti nr de nr din sir: "; cin>>n;
  9.     cout<<"a= "; cin>>a;
  10.     for (i=2; i<=n; i++)
  11.     {
  12.         cout<<"b= "; cin>>b;
  13.         if (b!=0)
  14.         {
  15.             do
  16.             {
  17.                 r=a%b;
  18.                 a=b;
  19.                 b=r;
  20.             }while (r!=0);
  21.         }
  22.     }
  23.     if (a==0)
  24.         cout<<"Cmmdc nedefnit";
  25.     else
  26.         cout<<"Cmmdc este: "<<a;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement