JAVA排序汇总
import
java.util.Random;
/**
*
排序测试类
*
*
排序算法的分类如下:
*
1.
插入排序(直接插入排序、折半插入排序、希尔排序);
*
2.
交换排序(冒泡泡排序、快速排序);
*
3.
选择排序(直接选择排序、堆排序);
*
4.
归并排序;
*
5.
基数排序。
*
*
关于排序方法的选择:
*
(1)
若
n
较小
(
如
n≤50)
,可采用直接插入或直接选择排序。
*
当记录规模较小时,直接插入排序较好;否则因为直接选择移动的记录数少于直接插人,应选直接选择排序为宜。
*
(2)
若文件初始状态基本有序
(
指正序
)
,则应选用直接插人、冒泡或随机的快速排序为宜;
*
(3)
若
n
较大,则应采用时间复杂度为
O(nlgn)
的排序方法:快速排序、堆排序或归并排序。
*
*/
public
class
SortTest {
/**
*
初始化测试数组的方法
*
@return
一个初始化好的数组
*/
public
int
[] createArray() {
Random random =
new
Random();
int
[] array =
new
int
[10];
for
(
int
i = 0; i < 10; i++) {
array[i] = random.nextInt(100) - random.nextInt(100);
//
生成两个随机数相减,保证生成的数中有负数
}
System.
out
.println(
"==========
相关文档:
public static void getSysProp(){
Properties props = System.getProperties();
Set<Entry<Object,Object>> res = props.entrySet();
Iterator it = res.iterator();
while (it.hasNext())
{
Map.Entry e = (Map.Entry)it.next();
......
public class testthree {
public static void main(String[] args) {
testthree t = new testthree();
t.test();
}
private static void test() {
int d = 0;
int f = 4;
int x = 0;
int y = 6;
for (i ......
// 过滤特殊字符
public static String StringFilter(String str) throws PatternSyntaxException {
// 只允许字母和数字
// String regEx = "[^a-zA-Z0-9]";
// 清除掉所有特殊字符
S ......
package demo;
class InOut{
String str=new String("Between");
static int i=666;
int j=888;
final int k=999;
public void amethod(final int iArgs){
int it315;
final int x=111;
/*static*/ class Bicycle
{
//&n ......
Flex Java 上传 下载 组件 收藏
事前准备就是到http://commons.apache.org下载common-fileupload-1.1.1.jar以及common-io-1.2.jar两个包。
前台Flex代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" creationComplet ......