0分求助!!救救孩子吧QAQ
查看原帖
0分求助!!救救孩子吧QAQ
555898
dreeam楼主2021/12/21 17:46
#include<iostream>
using namespace std;
int main(){
	int a=2,b=0,n;
	cin>>n;
	cout<<2<<endl;
	for(int i=1;;i++){
		for(int y=2;y<i;y++){
			if(i%y==0){
				break;
			}
			if(y==i-1){
				a+=i;
				
				if(a>n){
				b++;
					cout<<b;
					return 0;
				}
				else{
					cout<<i<<endl;
					b++;
				}
				
			}
		}
	}
}
2021/12/21 17:46
加载中...