aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab3/CST116F2021-Lab3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CST116F2021-Lab3/CST116F2021-Lab3.cpp')
-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;
+ }
+
+
+ }
+ }