题目1135:字符串排序
2014-02-07 18:44
405 查看
import java.io.IOException; import java.io.FileReader; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.Scanner; import java.util.Comparator; import java.util.Arrays; class Main { public static final boolean DEBUG = false; public static void main(String[] args) throws IOException { BufferedReader cin; String s; if (DEBUG) { cin = new BufferedReader(new FileReader("d:\\OJ\\uva_in.txt")); } else { cin = new BufferedReader(new InputStreamReader(System.in)); } while ((s = cin.readLine()) != null) { if (s.length() == 0) continue; int n = Integer.parseInt(s); int i; String[] str = new String ; for (i = 0; i < n; i++) { s = cin.readLine(); if (s.compareTo("stop") == 0) { break; } str[i] = s; } Comparator<String> cmp = new Comparator<String>() { public int compare(String a, String b) { return a.length() - b.length(); } }; Arrays.sort(str, 0, i, cmp); for (int j = 0; j < i; j++) { System.out.println(str[j]); } } } }
相关文章推荐
- 【九度】题目1135:字符串排序
- 九度OJ 题目1135:字符串排序
- 题目1135:字符串排序
- 题目1135:字符串排序 Java/c++
- 题目1135:字符串排序
- 九度题目:字符串排序(1135)
- 九度OJ 题目1135:字符串排序
- 九度OJ题目1066:字符串排序
- Java字符串题目--去除重复字符并排序
- 九度 Online Judge 算法 刷题 题目1066:字符串排序
- 题目1066:字符串排序
- 题目1054 字符串内排序 九度Online Judge
- 九度OJ—题目1066:字符串排序
- 九度OJ 题目1066:字符串排序
- 题目1054:字符串内排序
- 题目1054:字符串内排序
- 九度oj-1135-字符串排序
- 笔试题目1-数字字符串排序
- JAVA-从题目看算法,将输入字符串进行排序并输出
- 九度OJ题目1054:字符串内排序