質問編集履歴

2

コード修正

2020/02/20 22:50

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -156,7 +156,7 @@
156
156
 
157
157
  // for (int i = 0; i < 4; ++i) {
158
158
 
159
- // std::cout << "operator " << ops_str[i] << ": " << half << " " << ops_str[i] << " " << sixth << " = " << half << ops[i] << sixth << "\n";
159
+ // std::cout << "operator " << ops_str[i] << ": " << half << " " << ops_str[i] << " " << sixth << " = " << half ops[i] sixth << "\n";
160
160
 
161
161
  // }
162
162
 

1

コード修正

2020/02/20 22:50

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -47,6 +47,14 @@
47
47
  public:
48
48
 
49
49
  Fraction(int numerator, int denominator) : numerator_(numerator), denominator_(denominator) {
50
+
51
+ if (denominator_ < 0) {
52
+
53
+ numerator_ *= -1;
54
+
55
+ denominator_ *= -1;
56
+
57
+ }
50
58
 
51
59
  reduce();
52
60