File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -110,3 +110,5 @@ Why would you format your input rather than just having the file contain "the nu
110
110
111
111
## [ Review 14] ( review/14.txt )
112
112
How do you plan the general layout of a graph? How do you reflect that layout in your code?
113
+
114
+ ## [ Exercise 1] ( exercise/01/01.cpp )
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ // I think this is more readable
4
+ int iterative_fac (int n) {
5
+ int j = 1 ;
6
+ while (n > 1 )
7
+ j *= n--;
8
+ return j;
9
+ }
10
+
11
+ // This is cooler though
12
+ int recursive_fac (int n) {
13
+ return n > 1 ? n * recursive_fac (n-1 ) : 1 ;
14
+ }
15
+
16
+ int main () {
17
+ for (int i = 0 ; i < 21 ; ++i) {
18
+ std::cout << i
19
+ << " ! == "
20
+ << recursive_fac (i)
21
+ << " (recursive) == "
22
+ << iterative_fac (i)
23
+ << " (iterative)\n " ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments