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