⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch25-9.c

📁 C语言程序设计上机指导与练习 冶金工业出版社 刘怀亮
💻 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 + -