//输入一个整数n,输出2到n之间的具体素数值

#include <iostream>

#include <algorithm>

#include <cmath>

using namespace std;

int Juge(int n)

{

int j;

for(j=2;j<=sqrt(n);j++)

{

if(n%j==0)

return 1;

}

return 0;

}

int main()

{

int n,i;

cout<<"请输入整数n=";

cin>>n;

cout<<"素数是:";

for(i=1;i<=n;i++)

{

if(Judge(i)==0)

cout<<i<<" ";

}

system("pause");

return 0;

}

编程菜鸟的日记-初学尝试编程-寻找2到n之间的素数并输出的更多相关文章

  1. 编程菜鸟的日记-初学尝试编程-寻找等长数组A与B(所含元素相同,顺序不同)相匹配的元素即a[i]=b[j]

    #include <iostream> using namespace std; void matching(int a[],int b[],int N) { int i=0; while ...

  2. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9

    #include <iostream> #include <fstream> #include <cstdlib> #include <string> ...

  3. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8

    #include <iostream> #include <fstream> #include <cstdlib> const int SIZE=20; using ...

  4. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7

    #include <iostream> #include <string> #include <cctype> using namespace std; int m ...

  5. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6

    #include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...

  6. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5

    #include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...

  7. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4

    #include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...

  8. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习3

    #include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...

  9. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2

    #include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...

随机推荐

  1. servlet保存会话数据---利用隐藏域

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletExcep ...

  2. JAVA 数据类型数组

    普通int: public class Array { //成员变量 private int[] data; private int size; //构造函数,传入数组的容量capacity构造Arr ...

  3. .NET成年了,然后呢?

    作者|Lex Li 编辑|郭蕾 这可能是唯一一篇系统回顾 .NET 发展的文章..NET 的成年礼到了,你会送它什么? 2014 年 11 月 12 日,美国纽约曼哈顿,多云,气温适宜.微软公司执行副 ...

  4. (6).NET CORE微服务 Micro-Service ---- AOP框架

    AOP 框架基础 要求懂的知识:AOP.Filter.反射(Attribute). 如果直接使用 Polly,那么就会造成业务代码中混杂大量的业务无关代码.我们使用 AOP (如果不了解 AOP,请自 ...

  5. 远程连接mongodb服务器

  6. hibnet 自动生成表格

    在pom文件中添加相关的依赖 在application.yml文件中添加配置信息 新建实体类Boy 项目运行,mysql就产生了一个boy表. 需要注意的是:当配置文件ddl-auto: create ...

  7. Java 异常处理的重要认识

    异常类的继承结构 Exception : 一般标识的是程序中出现的问题,可以直接使用try---catch处理. Error : 一般值得是JVM错误,程序中无法处理. 检测异常类需要在throws后 ...

  8. 用jquery设置的值,miniui.getData取不到

    用jquery设置的值,miniui.getData取不到

  9. 在mybatis中调用存储过程的时候,不能加工语句

    select count(0) from ({call pkg_business.P_ZZS_LYFPHJSKJQK ('2018-04')}) 这是错误的.

  10. 整合django和bootstrap框架

    环境: python版本:2.7.8 django版本:1.7.1 bootstrap版本:3.3.0 首先github上面有两个开源的项目用来整合django和bootstrap. https:// ...