运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
Python
C
Java
prev2 = 0 prev1 = 1 print(prev2) print(prev1) for fibo in range(18): newFibo = prev1 + prev2 print(newFibo) prev2 = prev1 prev1 = newFibo #Python
#include <stdio.h> int main() { int prev2 = 0, prev1 = 1; int newFibo; printf("%d\n", prev2); printf("%d\n", prev1); for(int fibo = 0; fibo < 18; fibo++) { newFibo = prev1 + prev2; printf("%d\n", newFibo); prev2 = prev1; prev1 = newFibo; } return 0; } //C
public class Main { public static void main(String[] args) { int prev2 = 0; int prev1 = 1; System.out.println(prev2); System.out.println(prev1); for(int fibo = 0; fibo < 18; fibo++) { int newFibo = prev1 + prev2; System.out.println(newFibo); prev2 = prev1; prev1 = newFibo; } } } //Java
Python 结果
C 结果
Java 结果
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181