Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct fractie {
- int nu;
- int nr;
- }f1,f2,f3;
- int cmmdc(int a, int b)
- {
- if(a!=0 && b!=0)
- {
- while(a!=b)
- {
- if(a>b)
- a-=b;
- else
- b-=a;
- }
- return a;
- }
- else
- {
- return 1;
- }
- }
- int main()
- {
- float rez;
- cin>>f1.nr>>f1.nu;
- cin>>f2.nr>>f2.nu;
- int c=cmmdc(f1.nu,f1.nr);
- f1.nu=f1.nu/c;
- f1.nr=f1.nr/c;
- c=cmmdc(f2.nu,f2.nr);
- f2.nu=f2.nu/c;
- f2.nr=f2.nr/c;
- cout<<f1.nr<<"/"<<f1.nu<<endl;
- cout<<f2.nr<<"/"<<f2.nu<<endl;
- if((1.0*f1.nr)/f1.nu > (1.0*f2.nr)/f2.nu)
- cout<<f1.nr<<"/"<<f1.nu<<endl;
- else
- cout<<f2.nr<<"/"<<f2.nu<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement