|
发表于 2020-6-22 16:26:41
|
显示全部楼层
本楼为最佳答案
本帖最后由 jackz007 于 2020-6-22 16:40 编辑
第 14 行
n % 4 可能得到的值是 0 , 1 , 2 , 3,永远不可能是 7!
再说了,你加上括号是几个意思?
- #include <stdio.h>
- int main(void)
- {
- int a = 1 , b = 1 , c , d ;
- printf("%18d" , a) ;
- for(c = 1 ; c < 40 ; c ++) {
- d = a + b ;
- a = b ;
- b = d ;
- if(! (c % 4)) printf("\n") ;
- printf("%18d" , a) ;
- }
- if(! (c % 4)) printf("\n") ;
- printf("%18d\n" , b) ;
- }
复制代码
编译运行实况:
- D:\bin\00.Exercise\C>g++ -o fib fib.c
- D:\bin\00.Exercise\C>fib
- 1 1 2 3
- 5 8 13 21
- 34 55 89 144
- 233 377 610 987
- 1597 2584 4181 6765
- 10946 17711 28657 46368
- 75025 121393 196418 317811
- 514229 832040 1346269 2178309
- 3524578 5702887 9227465 14930352
- 24157817 39088169 63245986 102334155
- 165580141
- D:\bin\00.Exercise\C>
复制代码 |
|