报未定义,不知道错在那
#include<conio.h>#include<math.h>
#include<stdio.h>
double countValue(int n)
{
int i;
double s=0;
for(i=1;i<n;i++)
if(i%3==0&&i%7==0)
s+=i;
return sqrt(s);
}
main()
{
printf("自然数之和的平方根=%f\n",countValue(1000));
progReadWrite();
}
progReadWrite()
{
FILE*fp,*wf;
int i,n;
float s;
fp=fopen("in.dat","r");
if(fp=NULL)
{
printf("数据文件不存在");
return;
}
wf=fopen("out.dat","w");
for(i=0;i<10;i++)
{
fscanf(fp,"%d\n",&n);
s=countValue(n);
fprintf(wf,"%f\n",s);
}
fclose(fp);
fclose(wf);
}