a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 52|回复: 0

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
1.此刻输入n个数字,以逗号,分隔;然后可选择升或者降序排序;按提交键就在另一页面显示按什么排序,结不美观为,供给reset
/ C7 _  S* B" u6 Q! \2 ?* Y0 N" Fimport java.util.*;
: J$ G  _7 b1 A. \3 {public class bycomma{ 6 i8 K7 R/ j3 t0 p) S1 z5 B
public static String[] splitStringByComma(String source){ 0 _3 v0 |7 R! j; r( T7 {7 P5 U
   if(source==null||source.trim().equals(""))
, o# i' q4 L0 j    return null; ! ~$ e7 g) g& t* S+ L
   StringTokenizer commaToker = new StringTokenizer(source,","); * @+ W$ ^! _- V
   String[] result = new String[commaToker.countTokens()];
- [0 C) e! p5 A   int i=0; * |6 B+ F, u/ i! x
   while(commaToker.hasMoreTokens()){ 6 k2 t* P3 Y3 `$ V
    result = commaToker.nextToken();
0 T- n' G2 c. M, R' n7 x    i++; ; U8 i& H3 [3 r$ S
   } 4 N: }. r1 j2 M* j7 w' i
   return result; , E+ L+ q+ O6 }4 k+ r# f# ^
}
% h: U  F1 `8 q" L' s) o8 J public static void main(String args[]){
" w$ s: X, N  T% G0 o) K String[] s = splitStringByComma("5,8,7,4,3,9,1"); 0 G! O6 `. M4 W
int[] ii = new int[s.length];
5 e# K# o& [) {4 r% x9 r7 ^ for(int i = 0;i
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-18 16:31 , Processed in 0.249674 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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