1.此刻输入n个数字,以逗号,分隔;然后可选择升或者降序排序;按提交键就在另一页面显示按什么排序,结不美观为,供给reset
0 i1 y+ g, K' r) E- d4 Eimport java.util.*; 0 s E6 |$ B- q1 M _& W4 |% E
public class bycomma{
6 o+ m7 r! z+ L* n" i) x. t) [ public static String[] splitStringByComma(String source){ & Z b1 R1 P8 ?) e8 {
if(source==null||source.trim().equals("")) + B$ a8 l: w1 L
return null; ) ^1 }, u: Q v/ G- d; `% X
StringTokenizer commaToker = new StringTokenizer(source,",");
! {* Y7 f& M! F4 L8 v! H1 y, h String[] result = new String[commaToker.countTokens()];
9 Y- N$ s6 e* T int i=0;
# e3 s7 ~9 I3 }' G! o4 k while(commaToker.hasMoreTokens()){
9 ^+ x8 R) @! N# W& _ result = commaToker.nextToken(); - | c) Y6 f4 L6 \& m3 o, V$ `
i++;
6 ~. }: V" k' O4 U0 M5 d } # X# d& @% l O, W+ e
return result; C5 {! \( `9 d
}
: D3 ?% g; ^# B r9 F public static void main(String args[]){
8 F8 i9 d% F/ T# n9 B: d. r String[] s = splitStringByComma("5,8,7,4,3,9,1"); % n0 \' r0 s2 |( B: c, q
int[] ii = new int[s.length]; 9 R6 y, ^( {. q {' i6 @! `. m
for(int i = 0;i |