Category Archives: 算法&数据结构

读书笔记-《数据结构》第二章-线性表的顺序存储

读书笔记 《数据结构》严蔚敏,第二章的线性表(顺序存储),C++描述。
List.h
#include
#include
typedef int Status;
enum S{OK=0,WRONG=-1};

typedef struct
{
 int *elem;
 int len;
 int listsize;
} List;

Status InitList(List &L)
{
 if((L.elem=new i[......]

继续阅读

读书笔记--《数据结构 C语言版》第一章

读书笔记 《数据结构》严蔚敏,第一章的三元组实现,C++描述。
Triplet.h
#include
typedef int *Triplet;
typedef int Status;
enum value{WRONG=-2,OK,TRUE=10,FALSE=11};
Status InitTriplet(Triplet &T,int e1,int e2,int e3)
{
 if((T=new int[3])==NULL)
  return WR[......]

继续阅读

STL中vector转数组(实际是数组的指针)

感谢:http://topic.csdn.net/t/20050429/20/3976956.html
感谢:http://yzyanchao.blogbus.com/logs/47796444.html

不过那边是转载自《effective stl》。
    std::vector很方便,但有时调用的函数的参数规定是数组,需要将vector转为数组,另外开辟一个空间,将vector一项项复制过去代价过大,可用下面的方法。
给定一个
vector<int[......]

继续阅读