Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int nwd (int a, int b)
  6. {
  7.        int c;
  8.  
  9.  
  10.        while (b != 0)
  11.        {
  12.                c = a % b;      
  13.                a = b;
  14.                b = c;
  15.        }
  16.  
  17.  
  18.        return a;
  19.  
  20. }
  21. int main()
  22. {
  23.     int a,b,c;
  24.     cin>>a;
  25.     for(int i = 0; i<a; i++)
  26.     {
  27.         cin>>b;
  28.         cin>>c;
  29.         cout<<nwd(b,c)<<endl;
  30.  
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement