5460 - C++ CH08 01

已知一个有理数类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

来源

蓝桥杯训练

时间限制 1 秒
内存限制 256 MB
讨论 统计
上一题 下一题