1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【实践课外】11.函数2/7-2 N阶楼梯上楼问题.c

20 lines
277 B
C
Raw Normal View History

2024-11-22 09:14:26 +00:00
#include <stdio.h>
int n, f[105] = {1, 1};
int main() {
scanf("%d", &n);
if (n == 1) {
printf("1\n");
} else {
for (int i = 2; i <= n; i++) {
f[i] = f[i - 1] + f[i - 2];
}
printf("%d\n", f[n]);
}
return 0;
}