📄 计算a到b之间的素数.txt
字号:
#include<iostream.h>
#include<iomanip.h>
#include<math.h>
void main()
{
long a,b,l=0;
cout<<"please input two numbers:\n";
cin>>a>>b;
cout<<"primes form"<<a<<"to"<<b<<"is:\n";
if(a%2==0)
a++;
for(long m=a;m<=b;m+=2)
{
double sqrtm=sqrt(m);
int i;
for(i=2;i<=sqrtm;i++)
if(m%i==0)
break;
if(sqrtm<i)
{
if(l++%10==0)
cout<<endl;
cout<<setw(5)<<m;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -