简单算法
文章平均质量分 67
xidianluke
这个作者很懒,什么都没留下…
展开
-
java version : Insert sort
public static void InsertSor(int data[]){int len;if(null == data || (len = data.length) return;}int j;for(int i=1; iif(data[i] int temp = data[i];for( j=i-1; j>=0 && data[j] > temp;原创 2014-08-10 17:55:15 · 402 阅读 · 0 评论 -
找出数组中只出现一次的数字
private static void findNum(int data[]){ int len; if(null == data || (len=data.length) return; } byte mBytes[] = new byte[256]; cha原创 2014-07-29 13:42:39 · 405 阅读 · 0 评论 -
java version:求子数组的最大和
//求子数组的最大和private static void findMaxSum(int data[]){int len ;if(null == data || (len=data.length) == 0){return;}int curSum =0;int maxSum = 0;int maxValue = data[0];int curValue;f原创 2014-07-30 22:15:56 · 457 阅读 · 0 评论 -
java version: Simple Selection Sort
public static void selectSort(int data[]){int len;if(null == data || (len=data.length) return;}int min;for(int i=0; imin = i;for(int j=i+1; jif(data[j] min = j;}}if(i != min)原创 2014-08-10 18:01:11 · 384 阅读 · 0 评论 -
字符串中 单词反转
直接上代码: private String onReversing(String str){ if(null == str || str.length() return null; } char strArray[] = str.toCharArray(); int le原创 2015-03-12 11:18:13 · 887 阅读 · 0 评论 -
java version : 查找有序数组中等于给定值的2个数
//查找有序数组中等于给定值的2个数private static void findNums(int data[], int sum){if(null == data || data.length return;}int len = data.length;int front = 0;int end = len -1;int curSum = 0;while(f原创 2014-07-30 21:58:56 · 1040 阅读 · 0 评论 -
QuickSort
private static void quickSort(int data[],int low,int high){int pivot;if(low pivot = findPivot(data,low,high);quickSort(data,low,pivot-1);quickSort(data,pivot+1,high);}}private static原创 2014-08-05 22:20:00 · 362 阅读 · 0 评论