//输入一个整数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. Ncurses - Panel

    当你需要创建许多窗口时,你很快就会发现它们会变得难以管理.Panel library提供了很好的解决方案. Panel 实际上是一个窗口,通过容器 - 栈 来管理,栈顶的 panel 是完全可见的,其 ...

  2. 使用 curses 函数库管理基于文本的屏幕

    curses 函数库提供了终端无关的方式来编写全屏幕的基于字符的程序.curses 还可以管理键盘,提供了一种简单易用的非阻塞字符输入模式. curses 函数库能够优化光标的移动并最小化需要对屏幕进 ...

  3. One point compactification

    Theorem (One point compactification) Any locally compact space \(X\) can be embedded in another comp ...

  4. 【AtCoder】ARC076

    ARC076 C - Reconciled? 如果\(N = M\) 答案是\(2N!M!\) 如果\(|N - M| = 1\) 答案是\(N!M!\) 否则答案是0 #include <bi ...

  5. c_数据结构_栈的实现

    #include<stdio.h> #include<stdlib.h> #define STACK_INIT_SIZE 100 #define STACKINCREMENT ...

  6. Mac mumu模拟器设置代理

    adb devices adb connect 127.0.0.1:5555 adb shell am start -a android.intent.action.MAIN -n com.andro ...

  7. sparkStreaming消费kafka-1.0.1方式:direct方式(存储offset到zookeeper)-- 2

    参考上篇博文:https://www.cnblogs.com/niutao/p/10547718.html 同样的逻辑,不同的封装 package offsetInZookeeper /** * Cr ...

  8. gitlab之三: gitlab邮件通知的配置

    参考 :  https://www.cnblogs.com/lovelinux199075/p/9072265.html gitlab 添加新用户后,会自动发送邮件到填写的邮箱. 实验版本:  11. ...

  9. 分解数据表(将一个datatable按数据量分隔成多个table)

    /// <summary> /// 分解数据表 /// </summary> /// <param name="originalTab">需要分 ...

  10. There is no setter for property named 可能产生的原因!

     There is no setter for property named 'operateIP ' in 'class com.chinaunicom.wsp.facade.entity.User ...