【数据结构】
文章平均质量分 51
leeonfield
来看文章的
展开
-
strstr函数用法小结
strstr 函数原型: char * strstr(char * str1,char * str2);功能就是找出在字符串str1中第一次出项字符串str2的位置(也就是说字符串sr1中要包含有字符串str2),找到就返回该字符串位置的指针(也就是返回字符串str2在字符串str1中的地址的位置),找不到就返回空指针(就是 null)。 在C语言中 strchr 和 strst原创 2014-05-01 13:28:18 · 16130 阅读 · 0 评论 -
深度优先搜索,两点间所有路径
#include #include int map[100][100];///map[i][j]为0表示i, j两点之间不通,为1表示有一条路 int stack[120], m=1, n, x, y;///存储路径 int visited[100]={0}; void dfs(int p) { visited[p]=1; int i, j; for(i=0;原创 2014-05-23 21:10:10 · 5767 阅读 · 1 评论 -
判断是否是平衡二叉树
#include #include using namespace std; typedef struct shu { char data; struct shu *rc,*lc; }BT; char *ch; char str[100]; void create(BT *&t) { if(*ch++=='#') t=NULL; else { t=(原创 2014-06-04 15:25:42 · 625 阅读 · 0 评论 -
二叉排序树查找
如果找到,返回比较的次数,否则返回-1#include using namespace std; #include #include typedef struct node { int key; int data; struct node *lc,*rc; }BT; //二叉排序树的插入 int insert(BT *&p,int k) { if(p==NULL)原创 2014-06-06 00:27:15 · 715 阅读 · 0 评论 -
哈希表的处理
//哈希表查找 int search(hash ha,int k) { int i=0,adr; adr=k%p; while(ha[adr].key!=-1&&ha[adr].key!=k) { i++; adr=(adr+1)%m; } if(ha[adr].key==k) retur原创 2014-06-06 08:51:58 · 559 阅读 · 0 评论 -
二叉排序树
typedef struct node { int key; int data; struct node *lc,*rc; }BT; //二叉排序树的插入 int insert(BT *&p,int k) { if(p==NULL) { p=(BT *)malloc(sizeof(BT)); p->key=k;原创 2014-06-05 22:23:52 · 530 阅读 · 0 评论 -
插入排序……
#include #include using namespace std; int a[100],n; void insert() { int i,j,temp; for(i=1;i<n;i++) { temp=a[i]; j=i-1; while(j>=0&&temp<a[j]) {原创 2014-06-01 01:11:55 · 558 阅读 · 0 评论 -
二叉树的简单操作
最近在做二叉树题目,s原创 2014-04-24 16:39:55 · 651 阅读 · 0 评论