//输入一个整数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. gradle构建时跳过指定tests

    https://blog.csdn.net/u012672646/article/details/58598532

  2. RPC远程过程调用实例

    什么是RPC RPC 的全称是 Remote Procedure Call 是一种进程间通信方式.它允许程序调用另一个地址空间(通常是共享网络的另一台机器上)的过程或函数,而不用程序员显式编码这个远程 ...

  3. zTree的使用教程

    1.首先去官网下载http://www.ztree.me/v3/main.php#_zTreeInfo 2.之后引入: <script src="js/jquery.ztree.all ...

  4. java流程控制语句总结

    1.选择结构 if 方式1: 格式: if(条件表达式) { 语句体; } 执行流程: 如果条件表达式值为true, 执行语句体 如果条件表达式值为false,不执行语句体 方式2: 格式: if(条 ...

  5. Python自带IDE设置字体

    打开Python 3.7.0 shell 点击菜单项 “”Options“”>"Configure IDLE" 可选择窗口的字体和大小 可选择背景主题颜色 可自定义配置

  6. aop日志记录

    1.自定义 package cc.mrbird.common.annotation; import java.lang.annotation.ElementType; import java.lang ...

  7. Codeforces 912C Perun, Ult!

    Perun, Ult! 恶心题, 好多细节... 啊, 好恶心啊. #include<bits/stdc++.h> #define LL long long #define fi firs ...

  8. 函数防抖 debounce

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. Java实现简单计算器、抽票程序

    计算器: import java.awt.BorderLayout; import java.awt.Container; import java.awt.Font; import java.awt. ...

  10. vue的中vuex为何需要mutation更新状态,vue-router的路由的理解

    ); ); ); history.back(); history.forward(); // 修改历史,包括二个方法pushState.replaceState二个方法(objState,title, ...