A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 北极雪871208   /  2014-3-30 19:52  /  8781 人查看  /  34 人回复  /   3 人收藏 转载请遵从CC协议 禁止商业使用本文


每天都来看一看
回复 使用道具 举报
来借鉴一下
回复 使用道具 举报
嘿嘿嘿嘿嘿嘿
回复 使用道具 举报
rehan 中级黑马 2015-2-22 16:10:12
24#
。。。。。。。。。。。。。。。
回复 使用道具 举报
rehan 中级黑马 2015-2-22 16:46:12
25#
有点难啊,怎么做???
回复 使用道具 举报
rehan 中级黑马 2015-2-22 21:48:27
26#
syw02014 发表于 2014-3-30 21:05
希望能帮到你:程序在控制台上显示内容:
61.53.231.249
61.54.231.9

你的方法是错误的,控制台上的顺序一点没变!
回复 使用道具 举报
学习了。。
回复 使用道具 举报
wujiemin 发表于 2014-10-7 15:39
这些都太麻烦了,直接利用set

public class Test06 {

给力,给力。
回复 使用道具 举报
感觉好复杂的样子啊
回复 使用道具 举报
stamSuper 发表于 2014-5-9 08:30
字符串不是有比较大小的方法么 ,直接用那个方法多好啊,没有必要这么麻烦

貌似字符串比较的话9会比236大,实现不了按数字比较,楼上那位加0的方法比较好
回复 使用道具 举报
/* 1.将IP的每一段都前面补两个0 2.将每一端都变成3位 //割成四段的IP 3.将其从大到小排列 4.将前面多余的0去掉 */ import java.util.*; import java.io.*; class RuXue1  {         public static void main(String[] args) throws Exception         {                 //System.out.println("Hello World!");                 IpSort();         }         public static void IpSort()throws Exception         {                 BufferedReader br=new BufferedReader(new FileReader("ruxue1.txt"));                 String line=null;                 StringBuffer sb=new StringBuffer();                 while ((line=br.readLine())!=null)                 {              sb.append(line+" ");                  }                   String str=sb.toString();                 //System.out.println(str);                                          //"61.54.231.245 61.54.231.9 61.54.231.246 61.54.231.48 61.53.231.249";                 //1.将IP的每一段都前面补两个0                 str=str.replaceAll("(\\d+)","00$1");                 //2.将每一端都变成3位                 str=str.replaceAll("0*(\\d{3})","$1");                 //割成四段的IP                 String[] s=str.split(" ");         //3.将其从大到小排列                 TreeSet<String> tree=new TreeSet<String>();                 for (String st:s)                 {                         tree.add(st);                 }                 for (String st:tree)                 {                         st=st.replaceAll("0*(\\d+)","$1");                         //打印字符串                         //4.将前面多余的0去掉                     System.out.println(st);                 }                           br.close();         } }
回复 使用道具 举报
看了半天,没有懂。
回复 使用道具 举报
我也不会这个,没有思路!
回复 使用道具 举报
66666666666666
回复 使用道具 举报
12
您需要登录后才可以回帖 登录 | 加入黑马