Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<stdio.h>
- #include<math.h>
- using namespace std;
- double GCD(double x, double y)
- {
- double value;
- value=fmod(x,y);
- if(value==0)
- return y;
- else
- GCD(x, value);
- }
- int main()
- {
- double num, den;
- cin>>num>>den;
- double numcopy=num,dencopy=den;
- num/=GCD(num,den);
- den/=GCD(numcopy,dencopy);
- cout<<"\n"<<num<<"\t"<<den;
- cout<<"\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment