C++记录
文章平均质量分 66
你是我心中一首歌
这个作者很懒,什么都没留下…
展开
-
C++ 中的四种类型转换机制详解
转自:http://www.cnblogs.com/jiangheng/p/3748051.htmlTips: This article based on Scott Meyers's > article 27: Minimize CastingC++规则的设计目标之一,是保证"类型错误"绝对不可能发生。理论上你的程序可以很“干净”的通过编译,就表示它并不企图在任何对象身上执行转载 2014-10-13 12:48:30 · 663 阅读 · 0 评论 -
00-自测1. 打印沙漏(20)
写了两个版本的沙漏,提交上去都是第三个测试点错,也不知道为什么。可能是输出格式也可能是其他的什么,自己太笨了,想了好久。#include #include #include #include using namespace std;int main(){ size_t N; char a; while (cin >> N >> a) { size_t sum = 0原创 2015-05-15 20:55:16 · 925 阅读 · 0 评论 -
逆序对的实现,利用逆序对特性
#include using namespace std;int g_count;templatevoid Merge(T(*arr)[n], size_t left, size_t r, size_t right){ if (left == right) return; // create new arrays int lnum = r - left + 1, rnum =原创 2015-05-27 16:55:33 · 459 阅读 · 0 评论 -
1023. Have Fun with Numbers (20)
#include #include #include using namespace std;void SetDoubleVal(string &Obj, string &Obj1){ vector arr(Obj.size()); for (int i = Obj.size() - 1; i >= 0;--i) { int nT = atoi(&Obj[i]) * 2;原创 2015-05-17 17:50:14 · 395 阅读 · 0 评论 -
02-线性结构2. Reversing Linked List (25)
#include #include #include #include using namespace std;struct Record{ string firstLoca; int NeedFirst; string NextLoca; Record *Next;};void free(Record *buff){ //if (buff->Next == nul原创 2015-05-18 18:30:44 · 418 阅读 · 0 评论 -
遍历二叉树,利用栈和只用固定存储空间,递归和非递归。
struct BinaryTreeDate { BinaryTreeDate *parent; BinaryTreeDate *left; int key; BinaryTreeDate *right; BinaryTreeDate(int Key) :key(Key), left(nullptr), right(nullptr), parent(nullptr){} };原创 2015-06-11 13:13:07 · 526 阅读 · 0 评论