ctf_htj的博客
ctf_htj · 共 4 篇文章
Collection之Set学习
Collection之Set学习 <!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter" /> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0" /> <v:f eqn="sum @0 1 0" /> <v:f eqn="s…
2011-10-23 15:45 · Java · 评论(0)
Apache commons Utils包学习
Apache commons Utils包学习 RandomStringUtils :生成随机的字符串 /** * 生成由数字组成的随机串 */ String s = RandomStringUtils. randomNumeric (10); System. out .println(RandomStringUtils. randomNumeric (10));//7337081788 /** * 用指定的字符生成随机串 */ String ss = RandomStringUtils. random (10, new char []{'a', 'b', 'c'}); System. ou…
2011-10-23 15:43 · 评论(0)
编程珠玑-翻转算法
问题:将一个n元一维向量向左旋转i个位置。如,当n=8且i=3时,向量abcdefgh旋转为defghabc.求解决方案。 1. 首先将x的前i个元素复制到一个临时数组中,然后将余下的n-i个元素向左移动i个位置,最后将最初的i个元素从临时数组中复制到x中余下的位置。但是,这种办法使用的i个额外位置产生了过大的存储空间消耗。 2. 定义一个函数将x向左旋转一个位置然后调用该函数i次。但该方法又产生了过多的运行时间消耗。 3. 要在有限的资源内解决该问题,显然需要更复杂的程序。有一个成功的方法有点像精巧的杂技动作:移动x[0]到临时变量t,然后移动x[i]至x[0],x[2i]至x[i],依次…
2010-08-06 11:17 · 评论(0)