public class Solution
 {
     public static void main(String[] args)
     {
         int[] prime = new int[50];
         prime[0] = 2;
         int i = 0;
         int j = 3;
         boolean judgment = false;
         while(true)
         {
             i = 0;
             while(i < 50 && prime[i] != 0)
             {
                 if(j % prime[i] == 0)
                 {
                     judgment = false;
                     break;
                 }
                 i++;
             }

             for(int k = 0; k < 50; k++)
             {
                 if(judgment == true && prime[k] == 0)
                 {
                     prime[k] = j;
                     break;
                 }
             }

             judgment = true;
             j++;

             if(prime[prime.length - 1] != 0)
                 break;
         }

         int count = 0;
         for(int k = 0; k < 50; k++)
         {
             System.out.print(prime[k] + " ");
             count++;
             if(count == 10)
             {
                 System.out.println();
                 count = 0;
             }
         }

     }
 }

HW6.6的更多相关文章

  1. HW6.30

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HW6.29

    public class Solution { public static void main(String[] args) { int count = 0; int[] card = new int ...

  3. HW6.28

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. HW6.27

    import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(S ...

  5. HW6.26

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW6.25

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW6.24

    public class Solution { public static void main(String[] args) { int count = 0; int color; int numbe ...

  8. HW6.23

    public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...

  9. HW6.22

    import java.util.Arrays; public class Solution { public static void main(String[] args) { int[][] ch ...

  10. HW6.21

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. spoj 39

    DP  完全背包问题 的   d[i] = min(d[i], d[i-w]+p)   d[i]表示当总重量为i时可装的最小价值 #include <cstdio> #include &l ...

  2. C++11 生产者消费者

    下面是一个生产者消费者问题,来介绍condition_variable的用法.当线程间的共享数据发生变化的时候,可以通过condition_variable来通知其他的线程.消费者wait 直到生产者 ...

  3. poj 2976 Dropping tests 0/1分数规划

    0/1分数规划问题,用二分解决!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> # ...

  4. live555源码研究(五)------DynamicRTSPServer类

    一.类DynamicRTSPServer作用 1,提供RTSP服务 二.类DynamicRTSPServer继承关系图

  5. JavaWeb学习总结(四十八)——模拟Servlet3.0使用注解的方式配置Servlet

    一.Servlet的传统配置方式 在JavaWeb开发中, 每次编写一个Servlet都需要在web.xml文件中进行配置,如下所示: 1 <servlet> 2 <servlet- ...

  6. nginx配置负载均衡与反向代理

    #给文件夹授权   1 chown -R www:www /usr/local/nginx #修改配置文件vim nginx.conf   1 2 3 4 5 6 7 8 9 10 11 12 13 ...

  7. 安装Ubuntu双系统系列——为Firefox安装Adobe Flash Player

    使用环境:OS:Ubuntu 12.04 LTSBrowser: Firefox 12.0Adobe Flash Player: install_flash_player_11_linux.x86_6 ...

  8. 简单的神经元算法实现(python)

    参考python代码如下 #perceptron x=[[1 ,0, 0],[1,0,1],[1, 1, 0],[1, 1, 1],[0,0,1],[0,1,0],[0,1,1],[0,0,0]] y ...

  9. OpenSSH 'child_set_env()'函数安全绕过漏洞

    漏洞版本: OpenSSH 6.x 漏洞描述: Bugtraq ID:66355 CVE ID:CVE-2014-2532 OpenSSH是一种开放源码的SSH协议的实现. OpenSSH " ...

  10. 利用icepdf将pdf文件转为图片

    所需jar 包为icepdf-core.jar.icepdf-extra.jar.icepdf-pro-intl.jar.icepdf-pro.jar和icepdf-viewer.jar. 示例代码如 ...