- 题解
函数第二题
- 2023-11-24 20:19:45 @
#include <bits/stdc++.h>
using namespace std;
int cnt ;
int l (int h)
{
for (int i = 2; i <= h; i ++ )
{ bool is_prime = true;
for (int j = 2; j < i ;j ++ )
{
if (i % j == 0)
{ is_prime = false;
break;
}
}
if (is_prime == true)
cnt++ ;
}
return cnt ;
}
int main ()
{
int h;
cin >> h ;
cout << l(h) << endl ;
}
1 comments
-
经开一中2026届11班关泽瑞 LV 6 @ 2023-11-24 20:51:28
有实力👍 👍👍
- 1