Fork me on GitHub
摘要: 栈:#include "stdio.h"#include "stdlib.h"#define MAX_SIZE 100typedef struct stack{ int *base; int top;}Stack;int InitStack(Stack *stack){ stack->base=(int *)malloc(MAX_SIZE*sizeof(int)); if(!stack->base) return -1; stack->top=0; return 1;}int IsEmpty(Stack *stack){ if(0==s 阅读全文
posted @ 2012-07-27 21:29 zhanjindong 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 模式串匹配算法:#include "stdio.h"int Index(char *S,char *T,int pos){ int i,j,slen,tlen; slen=strlen(S); tlen=strlen(T); i=pos; j=0; while(i<slen&&j<tlen) { if(S[i]==T[j]) { i++; j++; } else { i=i-j+1;//如果j=0就相当于将i右移一位 ... 阅读全文
posted @ 2012-07-27 21:27 zhanjindong 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 二分查找using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Bsearch{ class Program { static void Main(string[] args) { int[] arr={1,2,3,4,5,6,7,8,9,10,11};//二分查找的对象是一个已经有序的顺序表 int r = Bsearch(arr,11); Console.Wr... 阅读全文
posted @ 2012-07-27 19:07 zhanjindong 阅读(258) 评论(0) 推荐(0) 编辑
TOP