fork download
  1. #include <stdio.h>
  2. //フィボナッチ数列(再帰なし版)
  3. int main(void) {
  4. int n = 10;
  5. //ここを埋める
  6. int a,b,c;
  7. b=1;
  8. c=1;
  9.  
  10. for(int i = 3; i <= n; i++){
  11. //ここも埋める
  12. a=b+c;
  13. c=b;
  14. b=a;
  15. }
  16. printf("フィボナッチ数列の第%d項は%d\n", n, a);
  17. return 0;
  18. }
  19.  
  20.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
フィボナッチ数列の第10項は55