编辑代码

/*------------------------------------------------------------------------
【程序设计】
--------------------------------------------------------------------------

题目:函数fun的功能:返回两个自然数n1、n2之间素数的个数。

例如:100~200间素数个数为21。       25    1 25 5  5     36   1 36   2  18   3  12  4   9    6 6    9  4   

------------------------------------------------------------------------
注意:部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容,仅在
      Program-End之间删除【?】填入若干语句。不要删除标志否则不得分。
----------------------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
int fun(int n1,int n2)
{
    /**********Program**********/
  

int m,i,k,n=0;
 for(m=n1;m<n2;m++)
 {    k=sqrt(m);
      for(i=2;i<=k;i++)
          if(m%i==0)  break;
      if(i>k)  n++;
  }
  return n;


    /**********  End  **********/

}
int main( )
{ 
    int count;
    count=fun(100,200);
    printf("素数个数是 %d\n",count);
    return 0;
}