csansoon

P4.15 X00639 Comparing fractions

Oct 24th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool c_frac(int n1, int d1, int n2, int d2){
  5.     double dn1=n1,dd1=d1,dn2=n2,dd2=d2;
  6.     if ((dn1/dd1)<(dn2/dd2)) return true;
  7.     else return false;
  8. }
  9.    
  10. int main(){
  11.     int n1,d1,n2,d2;
  12.     cin >>n1>>d1>>n2>>d2;
  13.     cout<<c_frac(n1,d1,n2,d2)<<endl;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment