📄 primepro.cpp
字号:
/*
Name:
Copyright: Seu.Edu.Cn
Author: ufouser
Id: 09002611
Date:
Description:
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <memory>
#include <cmath>
using namespace std;
const long MAXSIZE = 100;
bool isPrime[MAXSIZE + 1];
int main()
{
memset(isPrime,1,sizeof(isPrime));
isPrime[0] = isPrime[1] = false;
double sqrtMax = sqrt(double(MAXSIZE));
for (long i = 2; i <= sqrtMax; ++i)
{
if (isPrime[i])
{
double MAXDi = double(MAXSIZE) / i;
for (long j = i; j <= MAXDi; ++j)
{
if (isPrime[j])
{
isPrime[i*j] = false;
}
}
}
}
long count = 0;
for (long i = 2; i < MAXSIZE; ++i)
{
if (isPrime[i])
{
cout << i << ' ';
count++;
}
}
cout << endl << "Total=" << count << endl;
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -