1.cpp 367 B

123456789101112131415161718
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int gcd(int a,int b){
  5. int r=a%b;
  6. while(r!=0){a=b;b=r;r=a%b;}
  7. return b;
  8. }
  9. void reduction(int x1,int x2,int* add_y1,int* add_y2){int g=gcd(x1,x2);*add_y1=x1/g;*add_y2=x2/g;}
  10. int main()
  11. {
  12. int a,b;
  13. cin>>a>>b;
  14. reduction(a,b,&a,&b);
  15. cout<<a<<" "<<b;
  16. system("pause");
  17. return 0;
  18. }