Tag Archives: 数据结构

《数据结构》读书笔记 第五章 行逻辑稀疏矩阵

写得好费劲啊。找了半天错,最后发现是rpos初始化出错了。
Matrix.h:行逻辑稀疏矩阵的基本操作
enum Statuses{WRONG=-1,OK=0};
enum Max{MAX_SIZE=100,MAX_RC=20};
typedef int Status;
typedef int Elem;
typedef struct
{
 int i,j;
 Elem e;
}Triple;
typedef struct
{
 int mu,n[......]

继续阅读

《数据结构》读书笔记 第五章 矩阵的顺序三元表存储

开始恢复写程序了,快正常了~这次的程序很难的,而且系列性啊……最让我惊诧的是看到了别人的减法算法,太牛了……
Matrix.h:定义了基本操作
#include <iostream>
using namespace std;
enum {OK=-1,WRONG=0,MAX=100};
typedef int Status;
typedef int Elem;
struct Triple
{
 int i,j;[......]

继续阅读

《数据结构》读书笔记 第五章 数组的顺序存储实现

昨天读《The C++ Programing Language Special Edition》确实觉得注释是很重要的,所以今天开始所有程序都要练习注释,尽量写出好的注释来:-)
Array.h : 定义了数组的顺序存储的基本操作
#include <iostream>
#include <cstdarg>
typedef int Elem;
typedef int Status;
enum {WRONG=-1,OK=0};
struct Array
{
/*-[......]

继续阅读

《数据结构》读书笔记 第四章 堆分配存储串及基本操作

堆分配前天的普通串比有如下优点:
(1)节省空间,用多少,分配多少!
(2)struct结构体体积小,减少了位对齐的机会,提高了效率
缺点:
(1)用了new所以记得delete
(2)结构上字符串从0开始,这个下标是很折磨人的
HString.h
#include <iostream>
enum {OK=0,WRONG=-1};
typedef int Status;
struct HString
{
 char *chars;
 int len;
}[......]

继续阅读