/*烟台大学计算机学院学生
*All right reserved.
*文件名称:数据结构——素数
*作者:杨飞
*完成日期:2014年8月228日
*版本号:v1.0
*对任务及求解方法的描述部分:数据结构——素数
*我的程序:*/
#include <iostream>
using namespace std;
bool panduan(int n);
int main()
{
int m=0;
int a;
cin>>a;
for(int i=2;i<a;i++)
{
panduan(i);
if(panduan(i)==true)
{
cout<<i<<" ";
m++;
if(m%10==0)
cout<<endl;
}
}
cout<<endl;
return 0;
}
bool panduan(int n)
{
for(int i=2;i<n-1;i++)
{
if(n%i==0)
return false;
}
return true;
}
运行结果:
心得体会:呵呵