02 2013 档案

摘要:Depth-first search:访问顺序: A, B, D, F, E, C, G.PseudocodeInput: A graph G and a vertex v of GOutput: A labeling of the edges in the connected component of v as discovery edges and back edges1 procedure DFS(G,v):2 label v as explored3 for all edges e in G.adjacentEdges(v) do4 if edg... 阅读全文
posted @ 2013-02-24 10:49 wouldguan 阅读(190) 评论(0) 推荐(0) 编辑
摘要:javapublic class Hello{ public static int binarySearch(int[] a, int key) { int lo=0, hi = a.length-1; while(lo <= hi) { int mid = lo + (hi - lo) / 2; if(key < a[mid]) hi = mid-1; else if(key > a[mid]) lo = mid+1; else return mid; } return -1; } public static vo... 阅读全文
posted @ 2013-02-21 15:07 wouldguan 阅读(121) 评论(0) 推荐(0) 编辑
摘要:唯一不可能错过你一直都在 阅读全文
posted @ 2013-02-20 22:21 wouldguan 阅读(114) 评论(0) 推荐(0) 编辑
摘要:出处:http://www.dewen.org/q/620#include <stdio.h>int judge(int num){ int min = 1; if(num < 0) { return 0; } else if(num == 0 || num == 1) { return 1; } else { int current = 2; while(1) { if(current * current < num) { min = current; current = min * 2; } ... 阅读全文
posted @ 2013-02-20 18:37 wouldguan 阅读(452) 评论(0) 推荐(0) 编辑
摘要:出处: http://www.cnblogs.com/pkuoliver/archive/2010/10/27/Convert-m-number-to-n-number.htmlC语言版:#include <stdio.h>void m2n(int m, char* mNum, int n, char* nNum){ int i=0; char c, *p = nNum; while(*mNum!='\0') i = i*m + *mNum++ - '0'; while(i) { *p++ = i%n + '0'; i /= n; } 阅读全文
posted @ 2013-02-20 17:13 wouldguan 阅读(283) 评论(0) 推荐(0) 编辑
摘要:public class Hello{ private static void quickSort(int data[], int low, int hight) { int i=low,j=hight; int mid=data[(low+hight)/2]; while(i <= j) { while(data[i]<mid) i++; while(data[j]>mid) j--; if(i<=j) { int temp = data[i]; data[i] = data[j]; data[j] = t... 阅读全文
posted @ 2013-02-20 10:28 wouldguan 阅读(2307) 评论(0) 推荐(0) 编辑
摘要:package com.temp;import java.util.ArrayList;public class PolymorphismTest{ /** * @param args */ public static void main(String[] args) { ArrayList<Human> persons = new ArrayList<Human>(); persons.add(new Male()); persons.add(new Female()); ... 阅读全文
posted @ 2013-02-10 22:36 wouldguan 阅读(357) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示