原创 智能指針(模擬實現auto_ptr,shared_ptr,scooeptr 以及定製刪除器c++ 實現)
#define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; template<class T> class Auto_ptr { public: Au
原创 c++ 實現動態順序表(拷貝構造 賦值運算符重載等操作)
#pragma once #include<iostream> #include<malloc.h> using namespace std; typedef int DataType; class SList { public: SLi
原创 從1打印到最大的n位數字(字符串模擬數字自加)
陷阱: 用最大的n位數-1(數字太大可能產生越界) 應該採用字符串模擬數字自加! 代碼如下: #include<iostream> using namespace std; int IsMax(char *number) { int
原创 c語言常見50題 及答案(遞歸 循環 以及常見題目)
#define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; #include<assert.h> #include<stdio.h> #include<st
原创 c語言常見50題 及答案(遞歸 循環 以及常見題目)
#define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; #include<assert.h> #include<stdio.h> #include<st
原创 劍指offer 連續子數組的最大和
在古老的一維模式識別中,常常需要計算連續子向量的最大和,當向量全爲正數的時候,問題很好解決。但是,如果向量中包含負數,是否應該包含某個負數,並期望旁邊的正數會彌補它呢?例如:{6,-3,-2,7,-15,1,2,2},連續子向量的最大和爲8
原创 數據結構之二叉樹(前序 中序 後續線索話非遞歸方式)
節點: enum LinkType { THREAD, LINK }; template<class T> struct ThredBinaryNode {
原创 c++ 深淺拷貝(傳統寫法 現代寫法)
簡單的賦值淺拷貝 class String { public : String(const char* str) : _str(new char [strlen(str )+1]) {
原创 c++ 寫時拷貝
寫時拷貝--Copy On Writ#define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; class String { public: String
原创 ;從1打印到最大的n位數字(字符串模擬數字自加)
陷阱: 用最大的n位數-1(數字太大可能產生越界) 應該採用字符串模擬數字自加! 代碼如下: #include<iostream> using namespace std; int IsMax(char *number) { int