输入任意两个数,满足10<m<n<=3200,然后程序输出m~n之间所有素数
测试程序如下:
int m = 0, n = 0;
int count = 0;
//int temp = 0;
bool NotSuShu ;
cout<<"Please input m and n:"<<endl;
cin>>m>>n;
if( !(m>10 && n >m && n <= 3200) )
{
cout<<"Invalid data.Please input again."<<endl;
return 0 ;
}
for(int i = m ; i <= n; i++)
{
NotSuShu = false ;
for(int j = 2; j < i/2 ; j++)
{
if(i%j == 0)
{
NotSuShu = true ;
break;
}
}
if(!NotSuShu)
{
count++;
cout<<i<<" ";
if(count == 8)
{
cout<<endl;
count = 0;
}
}
}
cout<<endl;