Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <cstring>
- #include <cstdlib>
- #include <string>
- #include <vector>
- using namespace std;
- class point
- {
- public:
- int x, y;
- void set(int x, int y){
- this->x = x;
- this->y = y;
- }
- };
- void zero(int w)
- {
- if(w >= 10 && w <= 99)
- cout << "0" << w;
- if(w <= 9)
- cout << "00" << w;
- if(w >= 100)
- cout << w;
- }
- class Fraction{
- private:
- int x, y;
- char q, w;
- int q1, q2, w1, w2;
- public:
- void read(){
- cin >> q1 >> q >> q2;
- x = q1;
- y = q2;
- cin >> w1 >> w >> w2;
- }
- Fraction(int x = 0, int y = 1){
- this->x=x;
- this->y=y;
- }
- Fraction operator + (const Fraction&s){
- int a, b;
- b=y*(w2);
- a=x*(w2)+(w1)*y;
- return Fraction(a,b);
- }
- void show(){
- cout << x << "/" << y;
- }
- };
- int main() {
- Fraction a,b, c;
- a.read();
- c = a+b;
- c.show();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement