a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 148|回复: 0

[考试试题] JAVA编程经典模拟题:排序和金额转换

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-22 08:03 , Processed in 0.338921 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表