123456789101112131415161718 |
- #include <iostream>
- #include <math.h>
- using namespace std;
- int gcd(int a,int b){
- int r=a%b;
- while(r!=0){a=b;b=r;r=a%b;}
- return b;
- }
- 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;}
- int main()
- {
- int a,b;
- cin>>a>>b;
- reduction(a,b,&a,&b);
- cout<<a<<" "<<b;
- system("pause");
- return 0;
- }
|