From f73cf1220bdeb420d4fa305fc7b0f7a8bcbc4593 Mon Sep 17 00:00:00 2001 From: WiserJ Date: Tue, 19 Oct 2021 17:14:50 -0700 Subject: break time --- CST116F2021-Lab3/CST116F2021-Lab3.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.cpp b/CST116F2021-Lab3/CST116F2021-Lab3.cpp index 61ab7aa..7bdb00e 100644 --- a/CST116F2021-Lab3/CST116F2021-Lab3.cpp +++ b/CST116F2021-Lab3/CST116F2021-Lab3.cpp @@ -9,21 +9,38 @@ int main() { //p.192 - int input = 0, seq1 = 0, seq2 = 0; + int input = 0, prev = 1, next = 1; cout << "Please enter your ending number: "; cin >> input; - do + if (input == 1) + cout << prev << ' ' << next; + else { - if (seq1 == 0) - seq1 = seq1++; - - seq2 = seq1 + seq2; - } while (seq1 <= input || seq2 <= input); - - return 0; + cout << prev << " " << next << ' '; + while (next <= input) + { + next += prev; + cout << next << ' '; + + if (prev == 1) + { + next += prev; + cout << next << ' '; + prev += prev; + } + else + { + next += prev; + cout << next << ' '; + prev += prev; + } + + + } + } -- cgit v1.2.3