- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
constexpr Fraction operator+(const Fraction& fraction) const noexcept
{
const Fraction max_fraction_by_denominator{denominator > fraction.denominator ? *this : fraction};
const Fraction min_fraction_by_denominator{denominator < fraction.denominator ? *this : fraction};
const bool is_sim_denominator = max_fraction_by_denominator.denominator %
min_fraction_by_denominator.denominator == 0;
int sim_denominator = is_sim_denominator ?
max_fraction_by_denominator.denominator : (max_fraction_by_denominator.denominator *
min_fraction_by_denominator.denominator);
const int nominator1 = is_sim_denominator ? (min_fraction_by_denominator.nominator *
max_fraction_by_denominator.denominator / min_fraction_by_denominator.denominator) :
min_fraction_by_denominator.nominator * max_fraction_by_denominator.denominator;
const int nominator2 = is_sim_denominator ? max_fraction_by_denominator.nominator :
max_fraction_by_denominator.nominator * min_fraction_by_denominator.denominator;
int nominators_sum = nominator1 + nominator2;
int while_parts_sum = while_part + fraction.while_part;
while (nominators_sum >= sim_denominator)
{
nominators_sum -= sim_denominator;
++while_parts_sum;
}
if (!nominators_sum)
sim_denominator = 0;
return {while_parts_sum, nominators_sum, sim_denominator};
}
LispGovno 07.04.2016 08:53 # +1
А ю сириус?
Antervis 07.04.2016 09:08 # +1
> *this
нормально живем
Soul_re@ver 09.04.2016 00:15 # 0
guest 09.04.2016 00:20 # 0
Soul_re@ver 09.04.2016 14:00 # 0
http://coliru.stacked-crooked.com/a/f1db62fe3b0e8950
bormand 09.04.2016 14:07 # 0