标签:apple string The color dstat 自然数 大于 mes blank
1 #include<iostream> 2 #include<string> 3 #include<bitset> 4 #include<cmath> 5 6 using namespace std; 7 int main() 8 { 9 int const max_number(32); 10 int const max_test((int)sqrt((double)max_number)); 11 bitset<max_number + 1> number; 12 number.set(); 13 number[1] = 0; 14 for (int i(1); i!=max_test; ++i) 15 { 16 if (number[i]){ 17 //筛掉倍数 18 for (int j(i*i); j <max_number + 1; j += i) 19 { 20 number[j] = 0; 21 } 22 } 23 } 24 cout << "The number of the primes less than " << max_number + 1 25 << "is" << number.count() << endl; 26 for (int i(1); i != max_number + 1; ++i) 27 { 28 if (number[i]) cout << i << ","; 29 } 30 cout << endl; 31 system("pause"); 32 }
标签:apple string The color dstat 自然数 大于 mes blank
原文地址:https://www.cnblogs.com/dameidi/p/9313461.html