发生什么啦!?
查看原帖
发生什么啦!?
924336
DreamFlyboat楼主2024/7/7 14:52

请各位大佬指点一下在下

#include<bits/stdc++.h>
using namespace std;
int n,ans,t;
bool zs(int n){//判断质数(函数)
    int i=2;//最初质数
    bool b=true;//b初值为true
    if(n==1 || n==0)
        return false;//特判1和0
    else
        while(i*i<=n && b){//判断质数
            if(n%1==0)
                b=false;
            else
                i++;
    }
    return b;//返回
}
int main(){
    cin>>n;
    for(int j=1;j<=3000000 && t<=n;j++){//寻找第n小的质数
        if(zs(j)==true){
            ans=j;
            t++;
        }
//       cout<<ans<<' '<<t<<endl;
   }
    cout<<ans<<' ';
//    cout<<zs(4);//检查
    return 0;
}

这是出什么问题了!?

请各位帮忙看一下

2024/7/7 14:52
加载中...