From d65fbbd2556105fefebf4124918f5f5abeb1bdd3 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Tue, 16 Apr 2019 15:32:57 -0500 Subject: AHHHHHHH --- ee1301/wk6/hw6_directory/strap012_HW6B.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'ee1301/wk6/hw6_directory/strap012_HW6B.cpp') diff --git a/ee1301/wk6/hw6_directory/strap012_HW6B.cpp b/ee1301/wk6/hw6_directory/strap012_HW6B.cpp index 3426c52..d53ea08 100644 --- a/ee1301/wk6/hw6_directory/strap012_HW6B.cpp +++ b/ee1301/wk6/hw6_directory/strap012_HW6B.cpp @@ -5,23 +5,21 @@ #include int ff(int x); - int main() { - int value; + int x; do { std::cout << "Please enter a value of x: "; - std::cin >> value; - } while (value<0); + std::cin >> x; + } while (x<0); std::cout << "Beginning calculation of ff(x)...\n"; - int ffx = ff(value); - std::cout << "Calcuation complete, ff(x) = " << ffx << std::endl; + std::cout << "Calcuation complete, ff(x) = " << ff(x) << std::endl; } // This function either returns 1 when x is one of two recrusive conditions depending on if x is even or odd. int ff(int x) { if (x > 1) { if (x%2 == 0) { - //x is even + // x is even std::cout << "Calling ff(" << x/2 << ")\n"; return x*ff(x/2); } else { -- cgit v1.2.3