菲波那鍥數列

源代碼:

#include<stdio.h>

void writeDat();

int jsValue(int t)

{

int f0=0,f1=1;

int fn;

fn=f0+f1;

while(fn<t)

{

f0=f1;

f1=fn;

fn=f0+f1;

}

return fn;

}

void main()

{

  int n;

  n = 1000 ;

  printf("n = %d, f = %d\n", n,jsValue(n)) ;

  writeDat() ;

}

void writeDat()

{

  FILE *out ;

  int  s;

  out = fopen("OUT.DAT","w") ;

  s = jsValue(1000) ; printf("%d",s);

  fprintf(out, "%d\n", s) ;

  fclose(out) ;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章