质数(prime number)又称素数,有无限个。一个大于1的自然数,除了1和它本身外,不能整除以其他自然数(质数),换句话说就是该数除了1和它本身以外不再有其他的因数。
/**
* 判断100 ~ 200间素数的个数
*
* @author Administrator
*/
public class IsPrime {
public static void main(String[] args) {...
分类:
其他好文 时间:
2015-04-06 23:16:55
阅读次数:
176
题目:
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given
s = “leetcode”,
dict = [“leet...
分类:
其他好文 时间:
2015-04-06 21:53:21
阅读次数:
163
import java.util.Arrays;
/**
* 用Java产生100个1-150的数字
*/
public class RandomTest {
public static void main(String[] args) {
int[] resultArr = produceNum(1, 150, 100);
for (Integer num : resultAr...
分类:
编程语言 时间:
2015-04-06 21:53:14
阅读次数:
165
一、实现注册验证package com.pb.entity;import java.util.Date;/** * 用户实体类 * */public class User { /** * 住址 */ private String address; /** *...
分类:
其他好文 时间:
2015-04-06 21:40:15
阅读次数:
149
1.站内搜索1.1Lucene.Net建立信息索引 1 string indexPath = @"E:\xxx\xxx";//索引保存路径 2 FSDirectory directory = FSDirectory.Open(new Directo...
分类:
其他好文 时间:
2015-04-06 21:34:59
阅读次数:
178
join()方法示例如下: 1 public class Thread1{ 2 public static void main(String[] args) { 3 TestThread t=new TestThread("t"); 4 t.start(); ...
分类:
编程语言 时间:
2015-04-06 21:34:59
阅读次数:
231
题目链接:https://leetcode.com/problems/reverse-words-in-a-string/反转字符串的方法有很多种。要求空间复杂度是常数的话,可以先反转所有的单词,然后反转整个字符串。例如"the sky is blue",可以先反转为"eht yks si eulb...
分类:
其他好文 时间:
2015-04-06 21:29:12
阅读次数:
155
本周预期是分析字符串转换数值类型时候发生的异常。在C#中:int.Parse(String str):这种方法是将数字内容的字符串转换为int类型。如果字符串的内容为Null ,则抛出ArgumentNullException异常;如果字符串内容不是数字,则抛出FormatException异常。使...
分类:
其他好文 时间:
2015-04-06 21:28:05
阅读次数:
181
在我们处理字符串时,有时候会遇到这样一种情况:当输入的字符串不是全部由数字组成时,调用Integer.parseInt()函数时会抛出异常在遇到类似的情况时, 我们可以使用正则表达式来判断输入字符串是否匹配我们需要的模式,这时我们需要用到String类的match( )方法.此方法定义的语法如下:p...
分类:
其他好文 时间:
2015-04-06 21:27:26
阅读次数:
135
【题目】
Given a string containing just the characters '(' and ')',
find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substring i...
分类:
其他好文 时间:
2015-04-06 20:21:52
阅读次数:
113