• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

洛谷P5736【深基础7 实施例2]初始筛


Recommended Posts

第一参考代码

#includebits/stdc。h

使用命名空间std

/*

基础知识点3360

1.该功能的基本结构:

类型函数名(参数列表){

函数体,函数在return语句中终止。void类型函数可以不返回或写“return;”这样一句话

}

2.函数的调用:

使用函数名(参数),参数对应于参数表。

代码编写技巧3360

您可以使用一个空数组和一个累积变量来存储新生成的数据。

比如3360

声明: int new_num[10000],num _ cnt

新生成的数3360new _ num [num _ CNT]存储=新生成的数;

遍历所有新生成的数字:

for(int I=1;i=num _ cnti){

printf('%d\n ',new _ num);

}

*/

//在这里定义一个可以判断一个数是否是质数的函数judge(x)。

//如果能2到sqrt(x),则返回1(真),否则返回0(假)

布尔法官(long long num){

for(long long I=2;i * i=numi){

if(num % i==0)返回false

}

返回true

}

int num1[100 7],num2[100 7],CNT=0;

int main()

{

int n;scanf('%d ',n);

for(int I=1;I=n;i){

cinnum 1

//在这里调用函数。如果它不能是2的根号num1且不等于1,则它是素数。

if(judge(num1) num1!=1){

//使用上面提到的提示来存储这些数字

num 2[CNT]=num 1

}

}

//使用上述技术来遍历新数据

for(int I=1;i=cnti){

//在这里调整输出,输出非第一个数字前的空格。

如果(我!=1)cout“”;

cout num 2

} coutendl

返回0;

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now