![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
qq_38040674
这个作者很懒,什么都没留下…
展开
-
快速排序模板
//--------------------quicksort.cpp------------------------- template void split(ElementType x[],int first,int last) { ElementType pivot=x[first]; int left=first, right=last; while(left<right) {原创 2017-10-28 08:40:12 · 290 阅读 · 0 评论 -
基于链表的队列实现
//--------------LQueue.h------------------ #include #ifndef DQUEUE #define DQUEUE typedef int QueueElement; class Queue { public: Queue(); Queue(const Queue & original); ~Queue(); const Queu原创 2017-10-22 15:36:06 · 273 阅读 · 0 评论 -
有关数组与向量对比的小作业
对比数组和向量的使用方法。使用函数实现冒泡排序算法,传递参数分别为数组和向量,要求数据不被破坏。 #include #include using namespace std; void sort_array(int a[],int cap); //排序数组内元素的函数声明 void sort_vector(vectorv); //排序向量内元素的函数声明 voi原创 2017-10-20 17:24:59 · 587 阅读 · 0 评论 -
链表的相关操作
/*(1)编写一个算法判断链表中的数据项是否按从大到小排序,该链表的第一个节点由first指向。 (2)对于给定的整数n,编写一个算法把节点插入到链表中第n个节点之后的位置, 该链表的第一个节点由first指向。 (3)编写一个算法来颠倒一个链表,该链表的第一个节点由first指向。 不要复制列表元素:而是重置链表和指针,使得first指针指向原来的最后一个节点,原创 2017-11-09 16:39:19 · 1141 阅读 · 0 评论 -
链表的相关操作(2)
/* 给定两个数组A1和B1: 1)将A1和B1中的数据导入链表中,形成链表A2和B2,并打印各自链表元素; 2)将链表A2和B2中的元素各自排序(从大到小),形成链表A3和B3,并打印各自链表元素。 3)合并链表A3,B3,合并后的链表C的元素从大到小排列,并打印链表C。*/ //-----------------------LinkedList.h------------原创 2017-11-10 19:29:13 · 886 阅读 · 0 评论 -
Vector容器的简单实现
/*设计并实现完整的miniVector类,要求增加插入和删除函数,并测试主要的成员函数。 miniVector的基本功能应该包括以下几项:数组大小可调, 允许对任一元素赋值,修改,增加,删除并且不影响其他元素的正常访问。 扩展功能应包括允许通过下标访问,允许将一个对象复制给另一个对象,和其他功能。*/ //----------------------------------Vector.h原创 2017-10-25 17:09:54 · 1311 阅读 · 0 评论 -
Stack类模板
//-------------DStackT.h---------------- #include #ifndef DSTACK #define DSTACK template class Stack { public: Stack(int numElements=128); Stack(const Stack & original);原创 2017-10-25 21:11:50 · 315 阅读 · 0 评论 -
Hanoi塔问题
//-----------------------Hanoi.cpp----------------------------- #include #include using namespace std; void move(unsigned n,unsigned & moveNumber,char sourse,char destination,char spare); int main()原创 2017-10-25 22:29:44 · 154 阅读 · 0 评论 -
BST的实现
//--------------------BST.h--------------------------- #include #ifndef BINARY_SEARCH_TREE #define BINARY_SEARCH_TREE template class BST { public: BST(); bool empty() const; bool search(co原创 2017-10-26 19:49:33 · 292 阅读 · 0 评论 -
多项式加法的实现(链表版)
/*作业内容: 利用C++标准模板库的list实现多项式加法,可参考课本(P526-533) 求以下两个多项式的和: F(x)=8x7+7x4+3x2+5 G(x)=9x6+2x5+5x4+x+2 作业要求: 1. 要求采用类的设计思路; 2. 要求采用多文件的方式,包括类的头文件(.h文件), 类的实现文件(.cpp文件)和main函数文件(.cpp);*/ //-原创 2017-12-08 23:17:29 · 2522 阅读 · 0 评论 -
链表的相关操作(3)
/* 给定两个数组A1和B1: 1)将A1和B1中的数据导入链表中,形成链表A2和B2,并打印各自链表元素; 2)将链表A2和B2中的元素各自排序(从大到小),形成链表A3和B3,并打印各自链表元素。 3)合并链表A3,B3,合并后的链表C的元素从大到小排列,并打印链表C。*/ /* 11. 导入函数错误;扣2分; 有较小问题,扣1分; 12. 排序函数错误;扣2分; 有较小原创 2017-11-22 02:13:58 · 833 阅读 · 0 评论 -
基于动态数组的队列实现
//--------------DQueue.h------------------ #include #ifndef DQUEUE #define DQUEUE typedef int QueueElement; class Queue { public: Queue(int numElements=128); Queue(const Queue & original); ~Queu原创 2017-10-22 10:31:31 · 294 阅读 · 0 评论 -
基于数组的队列实现
//--------------Queue.h------------------ #include #ifndef QUEUE #define QUEUE const int QUEUE_CAPACITY=128; typedef int QueueElement; class Queue { public: Queue(); bool empty() const; void enq原创 2017-10-22 09:39:06 · 280 阅读 · 0 评论 -
链表实现的Stack类
//---------------LStack.h------------------- #include using namespace std; #ifndef LSTACK #define LSTACK typedef int StackElement; class Stack { public: Stack(); Stack(const Stack & original); ~S原创 2017-10-21 18:55:03 · 331 阅读 · 0 评论 -
八大排序算法
转载自http://blog.csdn.net/hguisu/article/details/7776068 概述 排序有内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存。 我们这里说说八大排序就是内部排序。 当n较大,则应采用时间复杂度为O(n转载 2017-10-28 08:43:22 · 753 阅读 · 0 评论 -
从头到尾彻底理解KMP
从头到尾彻底理解KMP 1. 引言 本KMP原文最初写于2年多前的2011年12月,因当时初次接触KMP,思路混乱导致写也写得非常混乱,如此,留言也是“骂声”一片。所以一直想找机会重新写下KMP,但苦于一直以来对KMP的理解始终不够,故才迟迟没有修改本文。 然近期因在北京开了个算法班,专门讲解数据结构、面试、算法,才再次仔细回顾了这个KMP,在综合了一转载 2017-10-28 08:52:14 · 205 阅读 · 0 评论 -
演示文件IO的例子
#include #include #include #include #include using namespace std; int main() { //-------------输入部分------------------ cout<<"Enter the name of the input file:"; string inputFileName; getline(cin,i原创 2017-10-20 16:51:46 · 212 阅读 · 0 评论 -
Linked List的相关操作
//--------------------------Linked_List---------------------------- //类声明 typedef int ElementType; class List { private: class Node { public: ElementType data; Node *next; Node(ElementType va原创 2017-10-28 19:27:26 · 233 阅读 · 0 评论 -
基于链表的列表实现
//-------------LinkedList.h-------------- #include #ifndef LIST #define LIST typedef int ElementType; class List { private: class Node { public: ElementType data; Node *next; Node(Eleme原创 2017-10-22 19:01:45 · 419 阅读 · 0 评论 -
以10为基转换为以2为基
#include #include using namespace std; int main() { unsigned number, remainder; stackstackOfRemainder; char response; do { cout<<"Enter positive integer to convert:"; cin>>numb原创 2017-10-20 23:14:46 · 271 阅读 · 0 评论 -
静态数组实现的Stack类
//-------------Stack.h---------------- #include #ifndef STACK #define STACK const int STACK_CAPACITY=128; typedef int StackElement; class Stack { public: Stack(); bool empty() const; void pus原创 2017-10-21 09:25:39 · 306 阅读 · 0 评论 -
基于数组的列表实现
//--------List.h---------- #include #ifndef LIST #define LIST const int CAPACITY=1024; typedef int ElementType; class List { public: List(); bool empty() const; void insert(ElementType item,i原创 2017-10-20 16:48:55 · 517 阅读 · 0 评论 -
动态数组实现的Stack类(完整版)
//-------------DStack.h---------------- #include #ifndef DSTACK #define DSTACK typedef int StackElement; class Stack { public: Stack(int numElements=128); Stack(const Stack & original); ~Stac原创 2017-10-21 14:08:35 · 365 阅读 · 0 评论 -
动态数组实现的Stack类(过渡版)
//-------------DStack.h---------------- #include #ifndef DSTACK #define DSTACK typedef int StackElement; class Stack { public: Stack(int numElements=128); bool empty() const; void push(const原创 2017-10-21 11:26:00 · 270 阅读 · 0 评论 -
基于动态数组的列表实现
//-------------DList.h-------------- #include #ifndef DLIST #define DLIST typedef int ElementType; class List { public: List(int maxSize=1024); ~List(); List(const List & origList); const List &原创 2017-10-20 19:42:30 · 311 阅读 · 0 评论