
算法策略
算法策略
乘风踏羽
这个作者很懒,什么都没留下…
展开
-
双向链表
#include "stdafx.h"#include #include #include //定义结点typedef struct __Node{ int data; struct __Node *pre; struct __Node *next;}Node;//定义带头结点的双向链表typedef struct __doublyLinkedList{ Node *转载 2014-10-19 20:51:07 · 505 阅读 · 0 评论 -
单链表经典实现
#include "stdafx.h"#include #include #include typedef struct Node{ int data; struct Node *next;} Node, *LinkedList;LinkedList createH(int arr[]){ //int arr[5] = {2, 4, 6, 1, 3}; LinkedL原创 2014-10-14 22:15:25 · 540 阅读 · 1 评论 -
练习
1、链表求两个有序链表的交集找出倒数第k个元素(或中间元素)链表排序http://www.vogella.com/code/index.htmlhttp://www.blogjava.net/zzheng/archive/2008/09/05/227305.html国际化http://nenyalanye-1.iteye.co原创 2012-08-14 00:01:58 · 571 阅读 · 0 评论 -
链表集锦
/* LNode表示该结构类,是该结构的一个实例LinkList是该结构类的指针,指代的是一个实例的地址他们的区别在于访问其成员不一样:LNode.dataLinkList->data举个通俗的例子:人小明站在河边。LNode相当于小明LinkList相当于 在河边的那个人当 LinkList=&LNode 时候就表示小明在河边 */typedef struct LNode转载 2012-08-13 07:11:17 · 402 阅读 · 0 评论 -
BM算法
#include #include #include #define MAX_NUM_CHAR 256int *makeSkip(char *pcPatternStr){ int iCnti; int iPatternLen = strlen(pcPatternStr); int *piSkip = (int*)malloc(MAX_NUM_CHAR *转载 2012-08-11 15:21:15 · 388 阅读 · 0 评论 -
KMP算法
#include#include#include int * geNext(char *pucPatternStr){ int iPatternLen; int *piNext; int iCnti; int iCntj; iCnti = 0; iCntj = -1; iPatternLen = strlen(pucPat原创 2012-08-11 12:08:52 · 348 阅读 · 0 评论 -
全排列集锦
/*1、递归全排列2、几种排列组合的算法3、堆全排列*/////////////////////////////////////////////////////////////////////////////////递归全排列#include int n = 0; void swap(int *a, int *b) { int m;转载 2012-07-31 23:28:36 · 549 阅读 · 0 评论 -
栈集锦
/*1、顺序栈2、双栈3、链栈4、顺序栈cpp*/////////////////////////////////////////////////////////////////////////////////////////顺序栈//Stack.h#define INFINITY 65535#define MAXSIZE 100typedef int ElemType;转载 2012-07-31 23:27:24 · 390 阅读 · 0 评论 -
哈希表集锦
/* 1、哈希表的地址链表法 *///////////////////////////////////////////////////////////////////////////////////////////哈希表的地址链表法/* 散列表(Hash table,也叫哈希表),是根据关键码值(Key value)而直接进行访问的数据结构。也就是说,它通过把关键码值映射到表中一转载 2012-07-31 22:54:09 · 392 阅读 · 0 评论 -
字符串集锦
/* 1、使用stringstream分割字符串2、KMP字符匹配算法3、Kmp字符串匹配算法改进版4、KMP算法之二*////////////////////////////////////////////////////////////////////////////////使用stringstream分割字符串,可以逐个输出#include #include #incl转载 2012-07-31 22:53:06 · 340 阅读 · 0 评论 -
树集锦
/* 1、二叉树的遍历:前序,中序,后序,层序--包括递归和非递归实现2、AVL树3、二叉查找树 */////////////////////////////////////////////////////////////////////////////////////////////二叉树的遍历:前序,中序,后序,层序--包括递归和非递归实现//tree.h/********转载 2012-07-31 22:52:08 · 394 阅读 · 0 评论 -
各类排序算法
//冒泡排序,稳定排序void BubbleFun(int arr[], int n){ int i,j;int temp; for(i=1; i<n; i++) for(j=0; j<n-i; j++){ if(arr[i]<arr[j]){ temp = arr[i];arr[j] = arr[i];arr[j] =temp;}原创 2011-11-04 12:48:03 · 494 阅读 · 0 评论 -
c++双向链表
#include "stdafx.h"#include//定义链表的结构体。struct MyList{ int nData; MyList* pPre; MyList* pNext;};//全局的变量,保存链表的头MyList* g_pHead = NULL;//判断链表是否为空bool IsEmpty(){ //如果头指针指向的是空,链转载 2011-11-04 12:42:55 · 422 阅读 · 0 评论 -
c++模板单循环链表
#include "stdafx.h"#includeusing namespace std;/*1 应用模板 2使用class定义node,而不是struct *///链表节点templateclass ListNode{public://引用public,避免了使用get,set所带来的麻烦 T data; ListNode*next;public: ListNode(转载 2011-11-04 12:42:03 · 1985 阅读 · 0 评论 -
c++链表添加删除修改
#include "stdafx.h"#include#include "assert.h"#include "windows.h"using namespace std;int _tmain(int argc, _TCHAR* argv[]){ return 0;}#define COUNT 3//定义一个节点结构体struct NODE{ unsigne转载 2011-11-04 12:41:02 · 4221 阅读 · 0 评论 -
HashMap用法
//HashMappackage com.mo.test;import java.util.Calendar;import java.util.*;public class HashMapTest{ public static void main(String[] args) { HashMap hashmap = new HashMap(); for (int i =转载 2011-11-04 13:03:51 · 755 阅读 · 0 评论 -
Hashtable用法
//Hashtable用法using System;using System.Collections.Generic;using System.Text;using System.Collections;namespace ConsoleApplication1{ class Program { public static void Main()转载 2011-11-04 13:04:27 · 412 阅读 · 0 评论 -
Queue用法
//Queue用法using System;using System.Collections.Generic;using System.Text;using System.Collections;namespace ConsoleApplication1{ class Program { static void Main(string[] args)转载 2011-11-04 13:05:08 · 462 阅读 · 0 评论 -
SortedList用法
//SortedListusing System;using System.Collections.Generic;using System.Text;using System.Collections;namespace ConsoleApplication1{ class Program { public static void Main()转载 2011-11-04 13:05:53 · 677 阅读 · 0 评论 -
stack用法
//stack用法using System;using System.Collections.Generic;using System.Text;using System.Collections;namespace ConsoleApplication1{ class Program { static void Main(string[] args)转载 2011-11-04 13:06:30 · 1665 阅读 · 0 评论 -
ArrayList 用法
//ArrayList 用法using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;namespace ConsoleApplication{ class Program { static v转载 2011-11-04 13:03:07 · 358 阅读 · 0 评论