原创 轉【STL學習】堆相關算法詳解與C++編程實現(Heap)

http://blog.csdn.net/xiajun07061225/article/details/8553808 堆簡介 堆並不是STL的組件,但是經常充當着底層實現結構。比如優先級隊列(Priority Queue)等等。

原创 C++中typename實例

#include <iostream> template<class T> class X { typename T::id i; public: void f() { i.g(); } }; class Y { publi

原创 用C++實現STL容器stack

template<class Object> class Stack { public: enum{STACK_SIZE = 20}; Stack(int n = 0):stack_top(0){ theSize = n + STAC

原创 堆排序算法實現

#include <stdio.h> int h[101];//用來存放堆的數組 int n;//用來存儲堆中元素的個數,也就是堆的大小 //交換函數,用來交換堆中兩個元素的數值 void swap(int x, int y) {

原创 C++模板函數

</pre><pre name="code" class="cpp">#include <iostream> #include <string> void printstring(const std::string & str) {

原创 特定的循環操作for_each

#include <iostream> #include <algorithm> #include <vector> using namespace std; template<class Type> class MultValue

原创 最強最方便的傻瓜式的vim配置

https://github.com/ma6174/vim 簡單安裝方法 打開終端,執行下面的命令就自動安裝好了: wget -qO- https://raw.github.com/ma6174/vim/master/setup

原创 用STL中的map容器實現從很多單詞找出所有隻有一個字母不同的單詞

對大約8900個單詞,從中找出所有的只有一個字母不相同的單詞。 最後一個算法不是特別清楚。。。。慢慢再看看 #include <iostream> #include <map> #include <string> #include <ve

原创 用C++實現二叉樹

#include <iostream> using namespace std; template<class Comparable> class BinarySearchTree { public: BinarySearchTre

原创 第十一章:運算符重載,友元函數,重載

運算符重載 1、什麼是運算符重載 運算符重載也就是同一個運算符在不同的運算表達式中表示的含義不一樣,也就是實現的功能不一樣。 比如:2*3 = 6,*號實現的功能是將兩個整數相乘。int num; int *pnum = &num;此時的

原创 linux 內核編譯

http://blog.csdn.net/wesleyluo/article/details/8005115 內核,是一個操作系統的核心。它負責管理系統的進程、內存、設備驅動程序、文件和網絡系統,決定着系統的性能和穩定性。Linux作爲

原创 中綴表達式轉換成前綴表達式和後綴表達式的極其簡單方法

35,15,+,80,70,-,*,20,/               //後綴表達方式(((35+15)*(80-70))/20)=25           //中綴表達方式  /,*,+,35,15,-,80,70, 20     

原创 C++類模板實例

#include <iostream> class A { int j; public: A(int x) :j(x) {} A(A *x) { j = x->j; } void operator!() { std::cout

原创 用C++實現STL容器vector

template<class Object> class Vector { public: enum {SPARE_CAPACITY = 16}; explicit Vector(int initsize = 0):theSize(i

原创 第十二章:默認複製構造函數和賦值運算符

默認複製函數 1、當把初始化一個對象的時候,用另一個已經存在的對象賦值。 比如String str2 = str1;其中str2爲已經生成的對象。這個時候,編譯器會把str1中的成員按值賦給str2中的每個成員。 如果對象成員中沒有使用