20分求助,优化!!!!!
查看原帖
20分求助,优化!!!!!
1411456
guangtougun楼主2024/8/18 19:31
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b = 0,i=2;cin>>a;
	while(i<=a){ 
		for(int j=2;j<=i;j++){
			if(i%j==0&&i!=j)break;
			else if(i==j){
				b++;break;
			}
		}
		i++;
	}
	printf("%d",b);
	return 0;
}
2024/8/18 19:31
加载中...