Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Ratio {
- public:
- int n,d;
- Ratio add(Ratio x){
- Ratio result;
- result.n=(n*x.d+x.n*d);
- result.d=(d*x.d);
- return result;
- }
- Ratio mul(Ratio x){
- }
- Ratio div(Ratio x){
- }
- Ratio subs(Ratio x){
- }
- bool equals(Ratio x){
- }
- };
- Ratio a, b,c;
- int main(void){
- a.n=2;
- a.d=4;
- b.n=1;
- b.d=2;
- c=a.add(b);
- cout<<c.n<<"/"<<c.d<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement