teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コード修正

2020/02/20 22:50

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -77,7 +77,7 @@
77
77
  // std::vector<std::string> ops_str{"+", "-", "*", "/"};
78
78
  // std::vector<std::operator> ops{operator+, operator-, operator*, operator/};
79
79
  // for (int i = 0; i < 4; ++i) {
80
- // std::cout << "operator " << ops_str[i] << ": " << half << " " << ops_str[i] << " " << sixth << " = " << half << ops[i] << sixth << "\n";
80
+ // std::cout << "operator " << ops_str[i] << ": " << half << " " << ops_str[i] << " " << sixth << " = " << half ops[i] sixth << "\n";
81
81
  // }
82
82
  }
83
83
  ```

1

コード修正

2020/02/20 22:50

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
  public:
25
25
  Fraction(int numerator, int denominator) : numerator_(numerator), denominator_(denominator) {
26
+ if (denominator_ < 0) {
27
+ numerator_ *= -1;
28
+ denominator_ *= -1;
29
+ }
26
30
  reduce();
27
31
  }
28
32