第八周專案5 計數的模式匹配

2021-07-06 06:53:43 字數 1402 閱讀 1361

問題及**:

/* 

*檔名稱:計數的模式匹配.cpp

*作 者:杜文文

*完成日期:2023年 10月 30日

*問題描述:採用順序結構儲存串,編寫乙個演算法計算指定子串在乙個字串中出現的次數,如果該子串不出現則為0。

解決這個問題,要查詢完整個字串,並將出現的次數記下來。

*/

sqstring.h

#ifndef sqstring_h_included

#define sqstring_h_included

#define maxsize 100 //最多的字元個數

typedef struct

sqstring;

void strassign(sqstring &s,char cstr); //字串常量cstr賦給串s

void strcopy(sqstring &s,sqstring t); //串t複製給串s

bool strequal(sqstring s,sqstring t); //判串相等

int strlength(sqstring s); //求串長

sqstring concat(sqstring s,sqstring t); //串連線

sqstring substr(sqstring s,int i,int j); //求子串

sqstring insstr(sqstring s1,int i,sqstring s2); //串插入

sqstring delstr(sqstring s,int i,int j) ; //串刪去

sqstring repstr(sqstring s,int i,int j,sqstring t); //串替換

void dispstr(sqstring s); //輸出串

#endif // sqstring_h_included

sqstring.cpp

#include #include "sqstring.h"

int str_count(sqstring s,sqstring t)

}return(count);

}void strassign(sqstring &s,char cstr) //s為引用型引數

void dispstr(sqstring s)

{ int i;

if (s.length>0)

{ for (i=0;i

執行結果:

第八周 專案5計數的模式匹配

all right reserved.檔名稱 project5.cpp 作 者 商文軻 完成日期 2015年10月20日 版 本 號 v1.9 問題描述 採用順序結構儲存串,編寫乙個演算法計算指定子串在乙個字串中出現的次數,如果該子串不出現則為0 程式採用多組織結構,用到順序串演算法庫sqstrin...

第八周 專案5 計數的模式匹配

檔名稱 main.cpp 作者 王超 完成日期 2015年10月23日 問題描述 計數的模式匹配 include include sqstring.h int main include include include sqstring.h int str count sqstring s,sqstr...

第八周專案5計數的匹配模式

問題及描述 輸入描述 sqstring.h ifndef sqstring h included define sqstring h included define maxsize 100 最多的字元個數 typedef struct sqstring void strassign sqstring...