蓝桥杯试题 算法训练 C++ CH08 01
资源限制
时间限制:1.0s 内存限制:256.0MB
问题描述
已知一个有理数类Zrf_Ratio,实现如下的操作符重载形式:
friend std::ostream& operator<<(std::ostream&, const zrf_Ratio&);//输出最简分数
friend std::istream& operator>>(std::istream&, zrf_Ratio&);
friend bool operator==(const zrf_Ratio&, const zrf_Ratio&);
friend bool operator<(const zrf_Ratio&, const zrf_Ratio&);
测试
测试时主程序会输入四个整数a, b, c, d,表示两个分数a/b和c/d。要求输出最简分数以及两个分数相等和大小的比较结果。
样例输入
1 7 26 25
样例输出
zrf is:1/7; ssh is:26/25
(zrf==ssh) is:0; (zrf<ssh) is:1