diff options
Fixed misplacement of false and true in hadRepeatingDigits functions of interval exercise
1 files changed, 3 insertions, 3 deletions
| -rw-r--r-- | Year 1/Object-oriented Programming/Solutions Sem. 05/ex2-interval.cpp | 6 |
diff --git a/Year 1/Object-oriented Programming/Solutions Sem. 05/ex2-interval.cpp b/Year 1/Object-oriented Programming/Solutions Sem. 05/ex2-interval.cpp index 92ecbcb..4b1b7ae 100644 --- a/Year 1/Object-oriented Programming/Solutions Sem. 05/ex2-interval.cpp +++ b/Year 1/Object-oriented Programming/Solutions Sem. 05/ex2-interval.cpp @@ -70,11 +70,11 @@ bool hasRepeatingDigits(int num) while (num != 0) { if (digitOccur[num % 10]) - return false; + return true; digitOccur[num % 10] = true; num /= 10; } - return true; + return false; } bool hasNotRepeatingDigits(int num) @@ -244,7 +244,7 @@ int main() Interval t4(0, 100), t5(-100, 0); std::cout << "Pal: " << t4.palindromesCount() << " " << t5.palindromesCount() << std::endl; // "19 1" (negatives arent palindromes) std::cout << "Primes: " << t4.primesCount() << " " << t5.primesCount() << std::endl; // "25 25" - std::cout << "Non repeat: " << t4.nonRepeatingDigitsCount() << " " << t5.nonRepeatingDigitsCount() << std::endl; // "10 10" + std::cout << "Non repeat: " << t4.nonRepeatingDigitsCount() << " " << t5.nonRepeatingDigitsCount() << std::endl; // "91 91" std::cout << t5.hasInInterval(-99) << t5.hasInInterval(0) << t5.hasInInterval(1) << std::endl; // "110" |
