搜索
您的当前位置:首页正文

求100以内的素数,全部打印出来

来源:意榕旅游网
//求100以内的素数,全部打印出来
#include <stdio.h>

int main()
{
    int i,j;
    int temp;

    for(i = 2;i <=100;i++)
    {
        int temp = 1;
        for(j = 2; j < i;j++)
	{
	    if(i % j == 0)
	    {
	        temp = 0;
	        break;
	    }
	}
	if(temp == 1)
	{
	    printf("%d ",i);
	}
    }

    return 0;
}

因篇幅问题不能全部显示,请点此查看更多更全内容

Top