c++
文章平均质量分 72
zybzmhhj
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
数据结构与算法分析课后习题第三章(3)
Exercises 3.3 Implement the STL find routine that returns the iterator containing the first occurrence of x in the range that begins at start and extends up to but not include end. If x is not found,原创 2007-03-02 21:58:00 · 2003 阅读 · 1 评论 -
Head first design patterns c++实现, decorator
//beverage.h component#ifndef BEVERAGE_H__#define BEVERAGE_H__#include class Beverage {public: Beverage():description("Unknown beverage"),cost(0){} virtual double Cost() = 0; virtual std::str原创 2007-03-06 19:55:00 · 722 阅读 · 0 评论 -
delete object, inline所需的注意及一些杂想
MFC经常会遇到创建画刷的句子CBrush* pBrush = new CBrush(RGB(0,0,0));CBrush* pOldBrush = dc.SelectObject(brush);//做点事情dc.SelectObject(pOldBrush);delete pBrush;delete dc.SelectObject(pOldBrush);//危险~!!原创 2007-03-06 20:14:00 · 664 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(11)
3.31 Efficiently implement a stack class using a singly linked list, with no header or tail nodes.3.32 Efficiently implement a queue class using a singly linked list, with no header or tail nodes.原创 2007-03-13 17:10:00 · 2086 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(10)
3.29 Write an algorithm for printing a singly linked list in reverse, using only constant extra space.This instruction implies that you cannot use recursion but you may assume that your algorithm is a原创 2007-03-13 16:55:00 · 2674 阅读 · 0 评论 -
数据结构与算法分析课后习题第四章(1)
4.11 Write an implementation of the set class, with associated iterators using a binary search tree. Add to each node a link to the parent node.4.12 Write an implementation of the map class by stori原创 2007-03-16 16:53:00 · 1798 阅读 · 0 评论 -
数据结构与算法分析课后习题第四章(2)
4.16 Redo the binary search tree class to implement lazy deletion. Note carefully that this affects all of the routines. Especially challenging are findMin and findMax, which must now be done recursiv原创 2007-03-16 17:05:00 · 2386 阅读 · 0 评论 -
数据结构与算法分析课后习题第四章(3)
4.38 The larger binary trees in this chapter were generated automatically by a program. This was done by assigning an (x,y) coordinate to each tree node, drawing a circle around each coordinate (this原创 2007-03-29 15:45:00 · 1296 阅读 · 0 评论 -
数据结构与算法分析课后习题第四章(4)
4.40 Write a routine to list out the nodes of a binary tree in level-order. List the root, then nodes at depth 1, followed by nodes at depth 2, and so on.4.44 Write a procedure to traverse a tree st原创 2007-03-29 15:59:00 · 4388 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(7)
3.19 Rewrite the List class without using header an tail nodes and describe the differences between the class and the class provided in Section 3.53.21 Write a program to check for balancing symbols原创 2007-03-06 18:33:00 · 1954 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(4)
exercise 3.6 The Josephus problem is the following game: N people, numbered 1 to N, are sitting in a circle. Starting at person 1, a hot potato is passed. After M passes, the person holding the hot po原创 2007-03-05 16:25:00 · 1247 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(8)
3.24 Write routines to implement two stacks using only one array. Your stack routines should not declare an overflow unless every slot in the array is used3.25 Propose a data structure that supports原创 2007-03-07 17:32:00 · 1745 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(2)
希望大家看过后对我自己写的这些笨方法提出意见,如果有问题也请及时指出,谢谢^^Exercise 3.2 Swap two adjacent elements by adjusting only the links ( and not the data ) usinga. Singly linked list.b. Doubly linked list //single.hpp#原创 2007-03-02 21:54:00 · 3439 阅读 · 1 评论 -
Head first design patterns c++实现, strategy
看了Head first design patterns,就自己试着用c++实现了一下,例子都和书上的一样,照猫画虎,不知道行不行 :)//flybehavior.h//strategy#ifndef FLYBEHAVIOR_H___#define FLYBEHAVIOR_H___class FlyBehavior {public: virtual void Fly() = 0;}原创 2007-03-02 22:17:00 · 760 阅读 · 0 评论 -
自己做的数据结构与算法分析(英文3版,weiss写的)的一些课后题
从第三章才开始做题,自己还是有些浮躁,以后看完要把会作的都做完再看下一章。练习3.1You are given a list, L, and another list P, containing integers sorted in ascending order. The operation printLots(L,P) will print the elements in L that a原创 2007-03-02 21:45:00 · 1977 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(5)
3.7 Modify the Vector class to add bounds checks for indexing.3.8 Add insert and erase to the Vector class.3.10 Modify the Vector class to provide stringent iterator checking by making iterator cl原创 2007-03-05 16:58:00 · 1234 阅读 · 0 评论 -
Head first design patterns c++实现, observer
//observer.h observer interface#ifndef OBSERVER_H__#define OBSERVER_H__class Observer {public: Observer(){} virtual ~Observer(){} virtual void Update() = 0;private: Observer(const Obs原创 2007-03-05 18:15:00 · 684 阅读 · 0 评论 -
数据结构与算法分析课后习题第三章(6)
Exercise 3.13 Add support for operator-- to the List iterator classes3.14 Looking ahead in an STL iterator requires an application of operator++, which in turn advances the iterator. In some cases l原创 2007-03-06 18:20:00 · 1320 阅读 · 1 评论 -
延后变量的定义
原来只是理解了这个的一部分,就是在使用前定义可以更明确的调用变量,不产生没有使用的变量,但是关于在循环中该如何处理这个问题一直没有考虑过,今天看了effectve c++才恍然大悟,先看:假设C是个定义好的类case1: C ob;while(i!=n) { ob = 取决于i的某个值; ++i;} case2:while(i!=n){原创 2007-03-06 20:06:00 · 619 阅读 · 0 评论 -
模板初步
最近看Thinking in c++ vol2感觉获益不少,今天看到STL感觉还是蛮震撼的,短短的几句话,简单的模版就解决了问题先看个例子: #include #include #include #include using namespace std;templateclass unary_composer { Func1 f1; Func2 f2;public: unary_原创 2007-03-06 20:17:00 · 650 阅读 · 0 评论 -
数据结构与算法分析课后习题第五章
5.3 Write a program to compute the nubmer of collisions required in a long random sequence of insertions using linear probing, quadratic probing, and double hashing.5.17 Implement a generic Map that原创 2007-03-29 16:07:00 · 1731 阅读 · 0 评论
分享