半懂不懂,大概能明白……程序是写出来了。
#include <iostream>
enum {MSL=100};
char S[MSL+1];
char T[20];
int next[20];
using namespace std;
void StrSet(char *S,char *T)
{
S[0]=strlen(T);
int i;
if(S[0]<=MSL)
{
&nbs[......]
Tag Archives: 数据结构
《数据结构》读书笔记 第四章 串的基本操作
String.h:串的基本操作
#include <iostream>
enum {MSL=20,WRONG=-1,OK=0};
typedef char SString[MSL+1];
typedef int Status;
Status StrAssign(SString S,SString T)
{
//一定注意长度不可以用T[0]表示!!
int len=strlen(T);
if(len<=len)
[......]
《数据结构》读书笔记 第三章 循环队列
终于是循环队列了,有点小麻烦,一定注意标红的几句不要忘记了!!
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:汉诺塔实现。
思路分析:
若n=1,则只需把盘子从a挪动到c
若n>1,
(1)把前n-1个盘子从a经过c挪动到b
(2)把第n个盘子从a挪动到c
(3)把前n-1个盘子从b经过a挪动回c
实现:
#include <fstream>
#include <iostream>
using namespace std;
ofstream fout("out.txt");
void Move(int n,char x,char y[......]