#include <iostream>
#include <sstream>
#include <string>
class Fraction
{
public:
Fraction( int numerator , int denominator = 1 );
std::string Add( Fraction );
private:
int numerator , denominator;
};
Fraction::Fraction( int numerator , int denominator )
: numerator( numerator ) , denominator( denominator ){}
std::string Fraction::Add( Fraction obj2 )
{
obj2.numerator *= denominator;
obj2.numerator += numerator * obj2.denominator;
obj2.denominator *= denominator;
std::stringstream ss;
ss << obj2.numerator << '/' << obj2.denominator;
return( ss.str() );
}
int main()
{
Fraction obj1( 2, 9 ) , obj2( 5 );
std::cout << obj1.Add( obj2 ) << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KCmNsYXNzIEZyYWN0aW9uCnsKCXB1YmxpYzoKCQlGcmFjdGlvbiggaW50IG51bWVyYXRvciAsIGludCBkZW5vbWluYXRvciA9IDEgKTsKCQlzdGQ6OnN0cmluZyBBZGQoIEZyYWN0aW9uICk7Cglwcml2YXRlOgoJCWludCBudW1lcmF0b3IgLCBkZW5vbWluYXRvcjsKfTsKCkZyYWN0aW9uOjpGcmFjdGlvbiggaW50IG51bWVyYXRvciAsIGludCBkZW5vbWluYXRvciApCjogbnVtZXJhdG9yKCBudW1lcmF0b3IgKSAsIGRlbm9taW5hdG9yKCBkZW5vbWluYXRvciApe30KCnN0ZDo6c3RyaW5nIEZyYWN0aW9uOjpBZGQoIEZyYWN0aW9uIG9iajIgKQp7CiAgICBvYmoyLm51bWVyYXRvciAqPSBkZW5vbWluYXRvcjsKICAgIG9iajIubnVtZXJhdG9yICs9IG51bWVyYXRvciAqIG9iajIuZGVub21pbmF0b3I7CiAgICBvYmoyLmRlbm9taW5hdG9yICo9IGRlbm9taW5hdG9yOwogICAgc3RkOjpzdHJpbmdzdHJlYW0gc3M7CiAgICBzcyA8PCBvYmoyLm51bWVyYXRvciA8PCAnLycgPDwgb2JqMi5kZW5vbWluYXRvcjsKICAgIHJldHVybiggc3Muc3RyKCkgKTsKfQoKaW50IG1haW4oKQp7CglGcmFjdGlvbiBvYmoxKCAyLCA5ICkgLCBvYmoyKCA1ICk7CglzdGQ6OmNvdXQgPDwgb2JqMS5BZGQoIG9iajIgKSA8PCBzdGQ6OmVuZGw7Cn0=