数据结构
ZhangCM_EDC
这个作者很懒,什么都没留下…
展开
-
C++实现list类
#pragma once #ifndef DSA_LIST_H #define DSA_LIST_H #define Posi(T) ListNode* //列表位置节点 templatetypename T>struct ListNode//列表节点模板类实现 { T data;//数值 Posi(T)pred;//前驱原创 2018-01-25 21:41:27 · 1148 阅读 · 0 评论 -
C++栈类的实现
#pragma once #ifndef DSA_STACK_H #define DSA_STACK_H templatetypename T>class Stack //不需要继承!!!继承的话就不需要里面藏一个deque!!! { private: std::deque Q; public: int size() { return Q.size(); }//返回规模原创 2018-01-25 22:39:53 · 636 阅读 · 0 评论 -
C++简单实现八皇后
bool isvalid(const vectorint>&p, int k) { for (int i = 0; i < k; i++) if (p[i] == p[k] ||abs( p[i] - p[k]) == abs(i - k)) return false; return true; } void rsolve(vectorint原创 2018-01-27 00:20:47 · 245 阅读 · 0 评论 -
Vector类实现(C++)
#pragma once #define DEFAULT_CAPACITY 10 templateclass Vector { private:int _capacity ; T*_elem; int _size;//容量默认为10,指向元素的指针,向量的规模 public: Vector(int c=DEFAULT_CAPACITY) { _elem = new T[_capacity =原创 2018-01-20 22:27:05 · 679 阅读 · 0 评论 -
leetcode-27. Remove Element--STL Vector remove()和erase()的使用
Given an array and a value, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-plac原创 2018-02-06 00:46:26 · 190 阅读 · 0 评论