60分求助!
查看原帖
60分求助!
759261
wangweichen666楼主2022/9/12 07:24
#include<bits/stdc++.h>
using namespace std;
int main(){
    int b,i,j,s,z;
    z=0;
    s=0;
    cin>>b;
    for(i=2;i<=b;i++){
    	int sq=sqrt(i);
        bool pr=true;
        for(j=2;j<=sq;j++){
            if(i%j==0){
            	pr=false;
                break;
            }
        }
        if(pr==true){
        	s++;
			}
		}
		cout<<s;
    return 0;
}
2022/9/12 07:24
加载中...