forked from LearningInfiniTensor/learning-cxx
-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy pathmain.cpp
More file actions
23 lines (20 loc) · 721 Bytes
/
main.cpp
File metadata and controls
23 lines (20 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "../exercise.h"
unsigned long long arr[90]{0, 1};
unsigned long long fibonacci(int i) {
switch (i) {
case 0:
return 0;
case 1:
return 1;
default:
return arr[i] ? arr[i] : (arr[i] = fibonacci(i - 1) + fibonacci(i - 2));
}
}
int main(int argc, char **argv) {
ASSERT(sizeof(arr) == 90 * sizeof(unsigned long long), "sizeof array is size of all its elements");
// ---- 不要修改以下代码 ----
ASSERT(fibonacci(2) == 1, "fibonacci(2) should be 1");
ASSERT(fibonacci(20) == 6765, "fibonacci(20) should be 6765");
ASSERT(fibonacci(80) == 23416728348467685, "fibonacci(80) should be 23416728348467685");
return 0;
}