
数据结构
gfgdsg
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
栈实现括号匹配
//[]()(())([<(]))#include#include#includeusing namespace std;int march(char str[]){stack kh;char ch,temp;int i,len;len=strlen(str);kh.empty();for(i=0;i<len;i++){ch=str[i];switch(ch){case '(':kh.push(c原创 2014-07-22 17:51:21 · 422 阅读 · 0 评论 -
和为s的两个数字 VS 和为s的连续正数序列
//和为s的两个数字 VS 和为s的连续正数序列 void TwoNumSum(int num[],int s,int len) { int i, j; for (i = 0; i < len; i++) { for (j = i + 1; j < len; j++) { if (num[i] + num[j] == s) { cout << num[i] <<原创 2014-10-10 11:45:55 · 464 阅读 · 0 评论 -
字符串的排列(去除重复项)
//The Arrange Of String abc ----abc,acb,bac,bca,cab,cba //Delete Repeat Arrange http://blog.youkuaiyun.com/hackbuteer1/article/details/7462447 //Q:here i use the recursion way to solove this question.What原创 2014-10-10 11:41:33 · 426 阅读 · 0 评论 -
字符串排列组合的应用
// String Combination字符串的排列 void Combination(char *string, int number, vector &result); void Combination(char *string) { assert(string != NULL); vector result; int i, length = strlen(string); for原创 2014-10-10 11:45:03 · 400 阅读 · 0 评论 -
选择排序 直接插入排序 希尔排序 堆排序
#include using namespace std; void InsertSort(int num[],int len)//没有哨兵 { int i,j,temp; for(i=1;i<len;i++) { if(num[i]<num[i-1]) { temp=num[i]; for(j=i-1;num[j]>temp;j--) { nu原创 2014-07-24 16:58:39 · 376 阅读 · 0 评论 -
二叉搜索树转化为双向链表
#include using namespace std; typedef struct Binode { int data; struct Binode *lchild,*rchild; }Binode,*Bitree; Bitree phead=NULL; Bitree pindex=NULL; void SortTree(Bitree &T,int element) { if(T==原创 2014-07-27 20:20:17 · 456 阅读 · 0 评论 -
append函数 两非递减链表的合并
#include using namespace std; typedef struct Node { int data; Node *next; }lnode,*list; list listinit() { list L; L=(lnode*)malloc(sizeof(list)); if(L==NULL) cout<<"没有足够的内存空间!"<<endl; L->next=原创 2014-07-27 20:23:47 · 488 阅读 · 0 评论 -
二叉树的前序中序后序遍历,非递归遍历 层次遍历
#include #include #include using namespace std; typedef struct Binode { char data; struct Binode *lchild,*rchild; }Binode,*Bitree; Bitree BitreeCreate() { Bitree T; char ch; cin>>ch; if(ch=='#')原创 2014-07-25 20:33:39 · 484 阅读 · 0 评论 -
归并排序递归
#include using namespace std; void Merge(int a[],int first,int mid,int end,int temp[]) { int i,m,j,n,k; i=first;m=mid;j=mid+1;n=end; k=0; while(i<=m&&j<=n) { if(a[i]<=a[j]) temp[k++]=a[i++];原创 2014-07-24 17:02:42 · 375 阅读 · 0 评论 -
如何判断链表中是否有环
1.如何判断是否有环?如果有两个头结点指针,一个走的快,一个走的慢,那么若干步以后,快的指针总会超过慢的指针一圈。 2.如何计算环的长度?第一次相遇(超一圈)时开始计数,第二次相遇时停止计数。 3.如何判断环的入口点:碰撞点p到连接点的距离=头指针到连接点的距离,因此,分别从碰撞点、头指针开始走,相遇的那个点就是连接点。 为什么呢?需要一个简单的计算过程: (1)当转载 2014-07-25 15:07:34 · 387 阅读 · 0 评论 -
栈实现计算器
#include"StdAfx.h" #include #include using namespace std; stacksdata; stacksoper; int isoper(char c) { if(c=='+'||c=='-'||c=='*'||c=='/'||c=='('||c==')'||c=='#') return 1; else return 0; } cha原创 2014-07-22 18:52:30 · 500 阅读 · 0 评论 -
层次遍历二叉树
#include"stdio.h" #include"stdlib.h" #include #include using namespace std; typedef struct BinaryNode { char data; BinaryNode *lchild; BinaryNode *rchild; } *BinaryTree; BinaryTree create() {原创 2014-07-23 11:59:27 · 833 阅读 · 0 评论 -
图的拓扑排序与关键路径
#include"StdAfx.h" #include #include #include using namespace std; typedef struct ArcNode { char adjvex; struct ArcNode *next; int v; }ArcNode; typedef struct VNode { char vertex; ArcNode *firstarc;原创 2014-07-22 20:08:00 · 517 阅读 · 0 评论 -
图的创建BFS DFS
#include"StdAfx.h" #include #include #include using namespace std; #define maxnode 64 typedef struct graph{ // string vexs[10]; int arc[10][10]; int vexnum,arcnum; }Graph; int visited[10]; int原创 2014-07-22 18:50:57 · 444 阅读 · 0 评论 -
链表的删除 合并 排序 反转
#include "stdafx.h" #include #include using namespace std; typedef struct Node { int data; Node *next; }LNode,*Linkedlist; Linkedlist LinkedlistInit() { Linkedlist L; L=(LNode*)malloc(sizeof(LNode原创 2014-07-22 18:56:02 · 385 阅读 · 0 评论 -
Prim算法
#include #include #include using namespace std; #define INF 64 typedef struct graph{ // string vexs[10]; int arc[10][10]; int vexnum,arcnum; }Graph; int visited[10]; int GraphLocateVertex(Graph原创 2014-07-22 21:53:25 · 387 阅读 · 0 评论 -
回溯法解决八皇后问题
//Eight Queen Problem Recall Way回溯法解决八皇后问题 #define max 8 int queen[max], sum = 0; int check(int n) { int i; for (i = 0; i < n; i++) { if (queen[i] == queen[n] || abs(queen[i] - queen[n]) == (n原创 2014-10-10 11:39:48 · 460 阅读 · 0 评论