堆分配前天的普通串比有如下优点:
(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;
}[......]
Tag Archives: 读书笔记
《数据结构》读书笔记 第三章 循环队列
终于是循环队列了,有点小麻烦,一定注意标红的几句不要忘记了!!
Queue.h:定义了基本操作
#include <iostream>
enum {QIS=5,QI=2};
enum {OK=0,WRONG=-1};
typedef int Elem;
typedef int Status;
typedef struct
{
Elem *base;
int front;
int rear;
int qsize[......]
《数据结构》读书笔记 第三章 非循环顺序队列1
《数据结构》读书笔记 第三章 非循环顺序队列的基本操作(出队列时候移除元素)
Queue.h:头文件,定义了参数和基本操作
#include <iostream>
enum {QIS=10,QI=2};
enum {WRONG=-1,OK=0};
typedef int Elem;
typedef struct
{
Elem *base;
int rear;
int memsize;
}Queue;
typedef int Stat[......]
《数据结构》栈实现进制转换
main.cpp:主程序
//Stack.h参见本分类下其它栈问题的描述
#include "../第三章 顺序栈的基本操作/Stack.h"
using namespace std;
int main()
{
int num,tmp=8;
Stack S;
InitStack(S);
cin>>num;
while(num!=0)
{
Push(S[......]
《数据结构》括号匹配问题的实现
main.cpp:主程序
//Stack.h参见本分类其它栈问题的记录。
#include "../第三章 顺序栈的基本操作/Stack.h"
using namespace std;
int main()
{
Stack S;
InitStack(S);
int tmp;
char c;
while((c=getchar())!='\n')
{
&nbs[......]