`
userya
  • 浏览: 7921 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论
阅读更多
/**
 * 
 * 
 */
package com

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.apache.commons.lang.StringUtils;

/**
 * @author userya
 * @since 2009-3-3 
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		System.out.println(trueTest("i", "her", "like", "ilikeher"));
		System.out.println(trueTest("i", "she", "like", "shelikei"));
		
	}

	/**
	 * test something
	 * @param a1
	 * @param a2
	 * @param a3
	 * @param target
	 * @return
	 */
	private static String trueTest(String a1, String a2, String a3,
			String target) {

		String temp = a1 + a2 + a3;
		int ii = 0;
		while (true) {
			ii++;
			if (StringUtils.isNotBlank(a3)) {
				char[] a = temp.toCharArray();
				Map map = new HashMap();
				for (int i = 0; i < a.length; i++) {
					map.put(i, a[i]);
				}
				StringBuffer sb = new StringBuffer();
				Random r = new Random();
				int j = map.size();
				while (true) {
					int rr = r.nextInt(j);
					if (map.containsKey(rr)) {
						sb.append(map.get(rr));
						map.remove(rr);
					}
					if (map.size() == 0) {
						break;
					}
				}
//				System.err.println(sb);
				if (target.equals(sb.toString())) {
					return "time:" + ii + "->" + sb.toString();
				}
			}
		}
	}
}


生活中总是有随机性,爱情也一样,但愿有生之年能跳出循环,找到平衡点。
分享到:
评论
2 楼 userya 2009-03-04  
除了骂人,文盲一个
1 楼 风花雪月饼 2009-03-04  
i like her
what?

she like i

哥们。你太逗了。

相关推荐

    probability and random processes.pdf

    随机信号处理英文教程probability and random processes This book has been written for several reasons, not all of which are academic. This material was for many years the rst half of a book in progress ...

    Random forests(Leo Breiman)

    Random forests are a combination of tree predictors such that each tree depends on the values of a random vector sampled independently and with the same distribution for all trees in the forest....

    【Java】Math.random()

    Math.Random()简介 Math.Random()函数能够返回带正号的double值,该值大于等于0.0且小于1.0,即取值范围是[0.0,1.0)的左闭右开区间,返回值是一个伪随机选择的数,在该范围内(近似)均匀分布。 for (int i = 0; i ...

    Python random库使用方法及异常处理方案

    1.random库的使用: random库是使用随机数的Python标准库 从概率论角度来说,随机数是随机产生的数据(比如抛硬币),但时计算机是不可能产生随机值,真正的随机数也是在特定条件下产生的确定值,只不过这些条件...

    Random伪随机数

    namespace 伪随机数{ class Program { static void Main(string[] args) { Random rnd=new Random (); char c; Random ro = new Random(); Console.WriteLine("{0}", ro); int d = ro.Next(); Console.WriteLine("{0...

    Machine Learning With Random Forests And Decision Trees - A Visual Guide

    An overview of decision trees and random forests A manual example of how a human would classify a dataset, compared to how a decision tree would work How a decision tree works, and why it is prone ...

    random函数使用详细讲解

    该文档是关于random函数使用详细讲解,主要在代码编写产生随机数的时候用到,详细介绍了random函数的各种用法,赶快下载看看吧~

    Probability, Random Variables and Random Signal Principles

    The primary goals of this book are to introduce the reader to the principles of random signals and to provide tools whereby one can deal with systems involving such signals . Toward these goals ,...

    Random Process for Engineers

    It is lecture notes for Random Process at UIUC, if you have interests, just have a look

    A Random Beamforming Technique

    Abstract—A random beamforming (RBF) technique is proposed to achieve omnidirectional coverage for broadcast channels in multipleantenna systems. In the proposed scheme, the time and frequency ...

    Android代码-random-beans

    Random Beans Because life is too short to generate random Java™ beans by hand.. Latest news 27/01/2019: Version 3.8.0 is finally out! Checkout what's new in the change log. 19/06/2017: ...

    import random.py

    import random n=input() x,y=n.split(',') '''将两个整数从输入提取出来''' list1=[] i=0 for i in range(0,100) : b=random.randint(int(x),int(y)) list1.append(b) #每次结果加插入列表 dic1={} for j in ...

    Probability & Random Processes for Electrical and Computer Engineers

    Probability & Random Processes for Electrical and Computer Engineers

    Random_Numbers_Android-master_randomnumbers_random_androidstudio

    Random Numbers with Android studio.

    ASP Random Images V1.0.2

    ASP Random Images ,好久才找到,很好用

    random bit generator_RandomNumber_random_源码

    Random bits generation with chaotic key sequence

    随机密码生成工具Random password

    如果你需要一款好用的密码生成工具,不妨试试小编带来的这款Random Password软件,功能强大全面,使用后可以帮助用户更轻松便捷的生成随机密码。用户可以根据自身的需要自定义密码的生成规律,包含了26个字母和数字...

    经典随机矩阵理论入门书:Random Matrices (Mehta,

    This book gives a coherent and detailed description of analytical methods devised to study random matrices. These methods are critical to the understanding of various fields in in mathematics and ...

    Random Number Generator v1.0

    Random Number Generator v1.0 &lt;br&gt;一个随机数生成的小工具,可以用在需要随机数的地方 例如随机安排考场座位, &lt;br&gt;功能: 1、生成数列的随机排序 2、指定前缀 3、关联目标 4、结果保存为文本...

    math.random用法

    math.random函数的一些用法技巧

Global site tag (gtag.js) - Google Analytics