From 0a885803acc1285ea5f875be3248c2e8f55ebe2d Mon Sep 17 00:00:00 2001 From: Financial-Theorist <93493045+Financial-Theorist@users.noreply.github.com> Date: Sun, 31 Oct 2021 22:03:29 -0400 Subject: [PATCH] Update ex1_11.cpp The original answer used an 'if' statement, which at that point in the book was not covered yet- thus could not be used as a valid answer by way of how the author intended a student to answer given the tools that they had been taught up to that point. This version uses only the tools presented up to the point of the exercise. --- ch01/ex1_11.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ch01/ex1_11.cpp b/ch01/ex1_11.cpp index 900f1d8d..60230fb2 100644 --- a/ch01/ex1_11.cpp +++ b/ch01/ex1_11.cpp @@ -4,21 +4,21 @@ int main() { - int small = 0, big = 0; - std::cout << "please input two integers:"; - std::cin >> small >> big; + std::cout << "Please enter an integer: "; + int number1 = 0; + std::cin >> number1; - if (small > big) { - int tmp = small; - small = big; - big = tmp; - } + std::cout << "Please enter one more integer: "; + int number2 = 0; + std::cin >> number2; - while (small <= big) { - std::cout << small << " "; - ++small; + while(number1 < number2){ + std::cout << number1 << std::endl; + ++number1; + } + while(number1 >= number2){ + std::cout << number1 << std::endl; + --number1; } - std::cout << std::endl; - return 0; }