Stack
摘要:1class StackX 2{ 3 private int maxSize; 4 private long[] stackArray; 5 private int top; 6 7 public StackX(int s) 8 { 9 maxSize=s; 10 stackArray=new lo...
阅读全文
posted @
2007-12-28 21:12
蓝蓝的天2016
阅读(144)
推荐(0)
插入排序 insertion Sort
摘要:插入排序 1public void insertionSort() 2{ 3 int in,out; 4 5 for(out=1;out0&&a[in-1]>=temp) 12 { 13 a[in]=a[in-1]; 14 --in; 15 } 16 a[in]=temp; 17 ...
阅读全文
posted @
2007-12-28 20:48
蓝蓝的天2016
阅读(104)
推荐(0)
选择排序 Selection Sort
摘要:选择排序 1public void selectionSort() 2{ 3 int out,in,min; 4 5 for(out=0;out<nElems-1;out++) 6 { 7 min=out; 8 9 for(in=out+1;in<nElems;in++) 10 if(a...
阅读全文
posted @
2007-12-27 22:22
蓝蓝的天2016
阅读(103)
推荐(0)
冒泡排序
摘要:Bubble Sort 1class ArrayBub 2{ 3 private long[] a; 4 private int nElems; 5 6 public ArrayBub(int max) 7 { 8 a=new long[max]; 9 nElems=0; 10 } 11 12 ...
阅读全文
posted @
2007-12-27 17:30
蓝蓝的天2016
阅读(126)
推荐(0)
Simple Sorting 简单排序
摘要:主要研究三种 Bubble Sort 冒泡排序 Selection Sort 选择排序 Insertion Sort 插入排序
阅读全文
posted @
2007-12-27 17:21
蓝蓝的天2016
阅读(96)
推荐(0)
storing Objects
摘要:在上一个例子中,我们存储的对象是原始的数据类型 long 在本文中,我们使用自定义的类,以期更符合我们在现实世界中遇到的情况 首先,自定义一个类 Person 1class Person 2{ 3 private string firstName; 4 private string lastName; 5 private int age; 6 ...
阅读全文
posted @
2007-12-27 17:05
蓝蓝的天2016
阅读(127)
推荐(0)
Binary Search with the find() Method
摘要:二分查找(java code) 1public int find(long searchkey) 2{ 3 int lowerBound=0; 4 int upperBound=nelems-1; 5 int curIn; 6 while(true) 7 { 8 curIn=(lowerBound+upperBound)/2; 9 ...
阅读全文
posted @
2007-12-27 16:24
蓝蓝的天2016
阅读(169)
推荐(0)