代碼如下所示:
代碼如下:
#include "stdafx.h"
#include <iostream>
#include <math.h>
bool IsSushu(int n)
{
bool IsSushuFlg = true;
if( n <= 1)
{
return false;
}
for( int i = 2; i <= (int)sqrt((double)n); i++ )
{
if( 0 == n % i )
{
IsSushuFlg = false;
break;
}
}
return IsSushuFlg;
}
#define N 1000
int main()
{
printf("Su shu is: /n");
for( int i = 2; i < N; i++)
{
bool IsSushuFlg = IsSushu(i);
if( IsSushuFlg )
{
printf("%d /n", i);
}
}
system("pause");
return 0;
}