满江红(0分求助)
查看原帖
满江红(0分求助)
1219475
yangbohao楼主2024/7/3 15:56
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,b,sum=1,num=0;
	cin>>n;
	for(int i=1;i<=100000;i++){
		if(i==1||i==0){
			continue;
		}
		else if(i==2){
			cout<<i<<endl;
		}
		else{
			for(int j=2;j<i-1;j++){
			    if(i%j!=0){
				    b=1; 
			    }
			    else if(i%j==0){
				    b=2;
				    break;
			    }
		    }
		    if(b==1){
			    cout<<i<<endl;
			    sum++;
			    num+=i;
			    if(num>=n){
			    	cout<<sum;
			    	return 0;
				}
		    }
		}	
	} 
    return 0;
} 

请大佬求助!

2024/7/3 15:56
加载中...