2012计算机二级c语言最新上机题库1.docVIP

  • 39
  • 0
  • 约 45页
  • 2016-12-27 发布于重庆
  • 举报
全国计算机二级C语言上机第03套:给定程序中,函数fun的功能是:将自然数1~10以及它们的平方根写到名为 myfile3.txt的文本文件中,然后再顺序读出显示在屏幕上。 #include math.h #include stdio.h 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++) /**********found**********/ ???fprintf(___1___,%d%f\n,i,sqrt((double)i)); ??printf(\nSucceed!!\n);/**********found**********/ ??___2___; ??printf(\nThe data in file :\n); /**********found**********/ ??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; } mai

文档评论(0)

1亿VIP精品文档

相关文档