Advertisement
Evgeniy175

Untitled

Dec 22nd, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. int main()
  3. {
  4. int m, n, a = 0, b = 0;
  5. std::cin >> m >> n;
  6. do
  7. {
  8. if (m > n) { m -= n; a++; b = n; }
  9. if (m < n) { n -= m; a++; b = m; }
  10. if (m == n) { a++; b = m; break; }
  11. if (n == 1 && n < m) { a += m; b = n; break; }
  12. if (m == 1 && n > m) { a += n; b = m; break; }
  13. } while (m != 0 || n != 0);
  14. std::cout << a << ' ' << b << std::endl;
  15. system("pause");
  16. return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement