求助,感觉也没问题啊
查看原帖
求助,感觉也没问题啊
933760
国孟宇2011楼主2023/6/8 13:21
#include<bits/stdc++.h>
using namespace std;
int ans,n,m;
bool ZSPD(int x){
	if(x==0 || x==1) return 0;
	for(int i=2;i<=x-1;i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}
int main() {
    cin>>n>>m;
    for(int i=n;i<=m;i++){
        if(ZSPD(i)==1) ans++;
    }
    cout<<ans;
    return 0;
}
2023/6/8 13:21
加载中...