素数

发布时间 2023-06-03 15:00:46作者: 软件拓荒人

一、问题描述:

 

二、设计思路:

 

 

三、程序流程图:

 

 

 

四、代码实现:

#include<stdio.h>
#define N 1000
#include<math.h>
int main()
{
    int start,end;
    int flag=1;
    int count=0;
    scanf("%d%d",&start,&end);
    for(int i=start;i<=end;i++)
    {
        for(int j=2;j<sqrt(i);j++)
        {
    
            if(i%j==0)
            {
                flag=0;
                break;
            }
        }
          if(flag)
        {
            printf("%-4d",i);
           count++;
        if(count%10==0)
            printf("\n");
        }
        flag=1;

    }
    printf("\nThe total is %d\n",count);
    return 0;
    
}