1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
using namespace std;
class rational
{
public:
int a,b,c,d;
int plus (int ,int ,int ,int );
int subtraction (int ,int ,int ,int );
int multiple (int ,int ,int ,int );
int divided (int ,int ,int ,int );
void printnumbers ();
};
int rational :: plus(int a,int b,int c,int d)
{
return a/b +c/d;
}
int rational :: subtraction(int a,int b,int c,int d)
{
return a/b - c/d;
}
int rational :: multiple(int a,int b,int c,int d)
{
return (a/b) * (c/d);
}
int rational :: divided(int a,int b,int c,int d)
{
return (a/b) / (c/d);
}
void rational :: printnumbers ()
{
cout<< (a/b) +(c/d);
cout<< (a/b) -( c/d);
cout<< (a/b) * (c/d);
cout<< (a/b) / (c/d);
}
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
rational p;
p.plus(a,b,c,d);
p.subtraction(a,b,c,d);
p.multiple(a,b,c,d);
p.divided(a,b,c,d);
p.printnumbers () ;
}
|