#include<iostream> using names

#include<iostream> 
using namespace std; 
const int SIZE = 100; 
int main()
 { int p[SIZE];
 int n, tot, i, cn;
 tot = 0; 
cin >> n;
 for (i = 1; i <= n; i++)
 p[i] = 1; 
for (i = 2; i <= n; i++) 
{ if (p[i] == 1)
 tot++; 
cn = i * 2; 
while (cn <= n) {
 p[cn] = 0; cn += i;
 }
 }
 cout << tot << endl;
return 0;
} 输入:30
输出:
不会做,求助#笔试题目#
全部评论

相关推荐

点赞 评论 收藏
转发
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务