#includeusing namespace std;const int SIZE = 100;int main(){\tint p[SIZE];\tint n, tot, i, cn;\ttot = 0;\tcin >> n;\tfor (i = 1; i <= n; i )\t\tp[i] = 1;\tfor (i = 2; i <= n; i ){\t\tif (p[i] == 1)\t\t\ttot ;\t\tcn = i * 2;\t\twhile (cn <= n) {\t\t\tp[cn] = 0;\t\t\tcn = i;\t\t}\t}\tcout << tot << endl;\treturn 0;}
输入: 30
输出:
发表评论 取消回复