Advertisement
STANAANDREY

pb 52

Jan 16th, 2019
159
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.     unsigned n,i,j,x,y,d;
  8.  
  9.     cout<<"n=";cin>>n;
  10.     cout<<"d=";cin>>d;
  11.    for (i=1;i<n;i++)
  12.       for (j=i+1;j<=n;j++)
  13.    {
  14.        x=i;y=j;
  15.        while (x!=y)
  16.        if (x>y)
  17.        x-=y;
  18.        else
  19.         y-=x;
  20.  
  21.        if (x==d)
  22.        cout<<'('<<i<<';'<<j<<')'<<',';
  23.    }
  24.    cout<<"\b \r";
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement