![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
mingxiaoshan
这个作者很懒,什么都没留下…
展开
-
智能指针的简单实现
#include <iostream>using namespace std;class A {public: A(int a, int b) { x = a; y = b; }; int x; int y; void test() { cout << "hello test!" << endl; };};template<typename T>.原创 2021-11-07 19:34:01 · 145 阅读 · 0 评论 -
扫描线求矩形面积
struct scanLine { int x1; int x2; int y; int cover; scanLine() {}; scanLine(int _x1, int _x2, int _y, int _cover) : x1(_x1), x2(_x2), y(_y), cover(_cover) {}; bool operator<(const scanLine & l) { return y < l.原创 2021-08-15 11:03:27 · 179 阅读 · 0 评论 -
手写 string 类
// 头文件#ifndef MYSTRING_H#define MYSTRING_H#include <iostream>#include <cstring>#include <cstdlib>using namespace std;class myString{ friend ostream & operator<<(ostream & out, myString &) ; friend istre.原创 2021-08-15 10:23:45 · 551 阅读 · 0 评论 -
手写红黑树
手写代码遇到了一些问题,先贴代码,以后慢慢讲。#include <iostream>#include <queue>using namespace std;#define RED 0 // 红色节点#define BLACK 1 // 黑色节点typedef int Key;typedef int Data;typedef struct _node { int color; Key key; Data data; ...原创 2021-07-28 16:04:52 · 83 阅读 · 0 评论 -
单链表排序(快排、归并)
// 快排 交换值void quickSort(ListNode * s, ListNode * t) { if(s == t || s->next == t) return ; ListNode * mid = partation(s,t); quickSort(s,mid); quickSort(mid->next,t);}LinkNode * partation(ListNode * s, ListNode * t) { if(s == t.原创 2021-06-21 16:37:08 · 88 阅读 · 0 评论 -
寻找平面上最近的点对
#include <stdio.h>#include <stdlib.h>#include <time.h>#define MAX_DIS 65536struct point{ int x; int y;};char result[64]="\0";int cmp_x(const void * p1, const void ...原创 2019-10-15 15:20:56 · 280 阅读 · 0 评论 -
K路归并的一个简单实现
#include <stdio.h>#include <stdlib.h>#include <time.h>struct NODE{ int data; //数据 int mark; //标记->来自哪一个数组} ;int node_num;void get_random_array(int *a, int l){...原创 2019-10-06 09:11:45 · 261 阅读 · 0 评论 -
字符串全排列 递归与非递归
#include <stdio.h>#include <stdlib.h>void swap(char * x,char * y){ char tmp=*x; *x=*y; *y=tmp;}//递归算法void permutation(char *s,int b,int e){ if(b==e) { ...原创 2019-03-08 10:40:23 · 466 阅读 · 1 评论 -
各种排序
#include <stdio.h>#include <stdlib.h>#include <time.h>int create_array(int a[]){ int i; srand(time(NULL)); int n=rand()%64; for(i=0;i<n;i++) { a[...原创 2019-03-07 09:33:08 · 130 阅读 · 0 评论 -
KMP字符串匹配
#include <stdio.h>#include <stdlib.h>#define MAX_SIZE 1024//原版的next数组void get_next(char *s,int next[]){ int l=strlen(s); int j=0; int k=-1; next[0]=-1; while(j&l...原创 2019-03-09 09:39:18 · 126 阅读 · 0 评论 -
最短路径问题
#include <stdio.h>#include <stdlib.h>#define MAX_SIZE 128#define INF 65536typedef int DATA;typedef struct{ int no; //编号 //DATA data; //数据} Vertex;typedef struct{ Ver...原创 2019-03-01 18:13:29 · 497 阅读 · 0 评论 -
链表 两个数相加
#include <stdio.h>#include <stdlib.h>struct ListNode{ int val; struct ListNode *next;};struct ListNode * createList(int a[],int length){ printf("create list\n"); in...原创 2019-02-23 15:42:23 · 358 阅读 · 0 评论 -
单链表上归并排序的实现
#include <stdlib.h>struct LinkList{ int data; struct LinkList * next;};void CreateLinkList(struct LinkList * );void DisplayLinkList(struct LinkList *);void DestoryLinkList(...原创 2016-11-09 18:10:24 · 639 阅读 · 0 评论 -
c 语言:一个链表的实现
#include #include typedef int ElementType;typedef int BOOL;#define TRUE 1#define FALSE 0inline BOOL compare(int a,int b,BOOL flag){ if(( a > b && !flag)||( a < b && flag)) return TRUE; else return FAL原创 2015-10-23 17:06:41 · 308 阅读 · 0 评论