Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Ratio {
  4.     public:
  5.         int n,d;
  6.         Ratio add(Ratio x){
  7.             Ratio result;
  8.             result.n=(n*x.d+x.n*d);
  9.             result.d=(d*x.d);
  10.             return result;
  11.         }
  12.         Ratio mul(Ratio x){
  13.         }
  14.         Ratio div(Ratio x){
  15.         }
  16.         Ratio subs(Ratio x){
  17.         }
  18.         bool equals(Ratio x){
  19.  
  20.         }
  21.  
  22.  
  23. };
  24. Ratio a, b,c;
  25. int main(void){
  26.     a.n=2;
  27.     a.d=4;
  28.     b.n=1;
  29.     b.d=2;
  30.     c=a.add(b);
  31.     cout<<c.n<<"/"<<c.d<<endl;
  32.     system("pause");
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement