1.此刻输入n个数字,以逗号,分隔;然后可选择升或者降序排序;按提交键就在另一页面显示按什么排序,结不美观为,供给reset
3 b+ _! h j, \+ {import java.util.*;
% L/ T4 W& h0 g! z$ O9 gpublic class bycomma{
& `5 Q3 n: Z# O5 Q- |3 {- S public static String[] splitStringByComma(String source){
/ \( s* V0 p& R5 R" o if(source==null||source.trim().equals(""))
) f+ `% [$ l7 T" _' ] return null; + Y& C" P3 l6 d/ w
StringTokenizer commaToker = new StringTokenizer(source,","); : J1 B% Z! q( l
String[] result = new String[commaToker.countTokens()];
2 i9 [" V1 M" U int i=0; # b( w$ G) s+ M0 d. Q
while(commaToker.hasMoreTokens()){
- I; e3 G; F- T. S. b result = commaToker.nextToken();
- @1 x7 ~2 }6 @) [ i++;
4 U' n) J2 m. O: k }
+ w( }& \( p& v7 { return result;
" I3 K: x; ~5 p: ~; X' ~ } ! d I+ ?. L; s; |
public static void main(String args[]){
$ ]5 m+ m5 H* @! U' q1 O String[] s = splitStringByComma("5,8,7,4,3,9,1"); h3 ]8 a0 N& @- C% G- u2 l9 N+ Z# o
int[] ii = new int[s.length]; ) s7 Y/ A9 \# M. I6 T! I" l Z
for(int i = 0;i |