11 2012 档案

摘要:2008-11-02 11:06算法:一个排序(第一个最大,第二个最小,第三个其次大,第四其次小...)问题:一组数字:21,25,11,32,12,35,55,77,66,写程序按照下面排序。(第1个数最大,第2个数最小,第3个数是剩下数中最大的,第4个是剩下数中最小的。。。)思路:先排序,然后在建立一个相同大小的数组,按照某种顺序复制过来代码:import java.util.Arrays;public class Test { public static void main(String[] args) { int[] a = new int[]{21,25,11,32,12,35,55 阅读全文
posted @ 2012-11-22 12:42 qiuhua 阅读(599) 评论(0) 推荐(0)
摘要:public class InsertionSorter { public void Sort(int[] arr) { for (int i = 1; i < arr.Length; i++) { int t = arr[i]; int j = i; while ((j > 0) && (arr[j - 1] > t)) { arr[j] = arr[j - 1];//交换顺序 --j; } arr[j] = t; } } } 阅读全文
posted @ 2012-11-22 12:21 qiuhua 阅读(124) 评论(0) 推荐(0)
摘要:2010-05-25 22:56js读写cookie//JS操作cookies方法!//写cookiesfunction setCookie(name,value){var Days = 30;var exp = new Date(); exp.setTime(exp.getTime() + Days*24*60*60*1000);document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();}//读取cookiesfunction getCookie(nam 阅读全文
posted @ 2012-11-19 21:51 qiuhua 阅读(183) 评论(0) 推荐(0)
摘要:不利用临时变量,交换两个变量的值Java代码public class ChangeValue{ /** * <不用第三个变量,交换两个变量的值> */ public static void main(String[] args) { //方法一 精简,一行代码搞定 int x = 3, y = 7, t = 123; System.out.printf("x = %d, y = %d\n", x, y); x = y + 0 * (y = x); System.out.printf("x = %d, y = %d\n", x, y); //方 阅读全文
posted @ 2012-11-19 21:49 qiuhua 阅读(178) 评论(0) 推荐(0)