HW6.6

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的更多相关文章
- HW6.30
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.29
public class Solution { public static void main(String[] args) { int count = 0; int[] card = new int ...
- HW6.28
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.27
import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(S ...
- HW6.26
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.24
public class Solution { public static void main(String[] args) { int count = 0; int color; int numbe ...
- HW6.23
public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...
- HW6.22
import java.util.Arrays; public class Solution { public static void main(String[] args) { int[][] ch ...
- HW6.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- 【leetcode】Word Ladder II(hard)★ 图 回头看
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from ...
- SDUT 2523 OOXX
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2523 思路 :就是先统计一下方阵中1多少2多少 ...
- [itint5]两有序数组的中位数
这个题和leetcode的基本一样.用了更好点的思路.在A中折半猜是不是中位数,A中没有后在B中猜.最后猜到B[j]<=A[i]<=B[j+1],此时,无论奇偶(2k+1或者2k个),A[ ...
- __init和__exit宏的作用
原文地址:http://blog.csdn.net/zhenwenxian/article/details/8564574 内核的部分函数带有__init和__exit宏,负责“初始化”和“清理收尾” ...
- ZOJ1586——QS Network(最小生成树)
QS Network DescriptionIn the planet w-503 of galaxy cgb, there is a kind of intelligent creature nam ...
- #error作用与举例
2013-09-05 14:32:17 #error命令是C/C++语言的预处理命令之一,当预处理器预处理到#error命令时将停止编译并输出用户自定义的错误消息. 语法: #error [用 ...
- Android 内核初识(1)下载源码需求与教程
官方文档: http://source.android.com/source/requirements.html Requirements The Android build is routinel ...
- 基于邻接表的广度优先搜索遍历(bfs)
题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2142&cid=1186 #include<stdio.h> #incl ...
- FreeMarker中if标签内的判断条件
reeMarker中的<#if>标签除了里面直接判断 boolean 类型的变量外,也可以进行表达式判断,有几个细节记录一下 1. 判断对象是否存在(null) 经常会用到,如果对象 != ...
- BZOJ_1031_[JSOI2007]_字符串加密_(后缀数组)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1031 长度为n的字符串形成环,枚举开头位置,得到n个长度为n的串,将这些串排序,然后按照顺序输 ...