串——顺序存储结构

本文深入探讨了串的顺序存储结构,通过头文件SqString.h、源文件SqString.cpp和主函数main.cpp来阐述相关实现和操作。
摘要由CSDN通过智能技术生成

该文章主要介绍串的顺序存储结构以及相关运算。

头文件:SqString.h

#ifndef SQSTRING_H_
#define SQSTRING_H_
#include <iostream>
const int MaxSize = 100;
class SqStringClass				//顺序串类
{
	char *data;					//存放串中元素
	int length;       			//串中字符个数
public:
	//===================顺序串的基本运算算法=================
	SqStringClass();									//构造函数
	~SqStringClass();									//析构函数
	SqStringClass &operator=(char *cstr);				//重载赋值运算符
	SqStringClass &operator=(SqStringClass &t);			//重载赋值运算符
	int StrLength();									//求串长度
	SqStringClass &operator+(SqStringClass &t);			//串连接
	SqStringClass &SubStr(int i, int j);				//求子串
	SqStringClass &InsStr(int i, SqStringClass &s);		//串插入
	SqStringClass &DelStr(int i, int j);				//串删除
	SqStringClass &RepStr(int i, int j, SqStringClass &s);//串替换
	void DispStr();										//串输出	
	//===================顺序串的其他运算算法===================
	friend bool StrEqueal(SqStringClass &s, SqStringClass &t);//比较两个串是否相等
	friend int Strcmp(SqStringClass &s, SqStringClass &t);//比较两个串的大小  <:-1 =:0 >:1

	//===================顺序串的串匹配运算算法================
	//以下为BF算法(暴力匹配)的友元函数声明
	friend int Index(SqStringClass &s, SqStringClass &t);

	//以下为KMPF算法的友元函数声明
	friend void GetNext(SqStringClass &t, int next[]);
	friend int KMPIndex(SqStringClass &s, SqStringClass &t);
};
#endif

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值