📄 ch25-9.c
字号:
#include <conio.h>
#include <math.h>
#include <stdio.h>
/*实现本程序有关平方根问题的countValue()函数*/
double countValue(int n)
{
int i;
double s=0.0;
for(i=1;i<n;i++)
if(i%21==0) s+=i;
return sqrt(s);
}
void progWrite()
{
FILE *wf;
int i,n;
float s;
wf=fopen("out.dat","w");
for(i=0;i<10;i++){
fscanf(wf,"%d\n",&n);
s=countValue(n);
fprintf(wf,"%f\n",s);
}
fclose(wf);
}
void main()
{
printf("自然数之和的平方根=%f\n",countValue(1000));
progWrite();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -