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