aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-19 17:14:50 -0700
committerWiserJ <[email protected]>2021-10-19 17:14:50 -0700
commitf73cf1220bdeb420d4fa305fc7b0f7a8bcbc4593 (patch)
tree9671c88365a518f6ce7a76d8c31e63fe590b80ba
parentp.192a (diff)
downloadcst116-lab3-jeffwoit-f73cf1220bdeb420d4fa305fc7b0f7a8bcbc4593.tar.xz
cst116-lab3-jeffwoit-f73cf1220bdeb420d4fa305fc7b0f7a8bcbc4593.zip
break time
-rw-r--r--CST116F2021-Lab3/CST116F2021-Lab3.cpp35
1 files 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;
+ }
+
+
+ }
+ }