2014年3月全国计算机二级C语言上机模拟试题二十二

2014-11-03 13:00:05 · 作者: · 浏览: 29

  请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。


  注意:源程序存放在考生文件夹下的BLANK1.C中。


  不得增行或删行,也不得更改程序的结构!


  给定源程序:


  #include


  #include


  int fun(char *fname )


  { FILE *fp; int i,n; float x;


  if((fp=fopen(fname, "w"))==NULL) return 0;


  for(i=1;i<=10;i++)


  fprintf(___1___,"%d %f\n",i,sqrt((double)i));


  printf("\nSucceed!!\n");


  ___2___;


  printf("\nThe data in file :\n");


  if((fp=fopen(___3___,"r"))==NULL)


  return 0;


  fscanf(fp,"%d%f",&n,&x);


  while(!feof(fp))


  { printf("%d %f\n",n,x); fscanf(fp,"%d%f",&n,&x); }


  fclose(fp);


  return 1;


  }


  main()


  { char fname[]="myfile3.txt";


  fun(fname);


  }