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

2021-07-23 21:47:05 字數 1610 閱讀 7482

問題及**:

/*

*檔名稱:1.cpp

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

*版本號:v1.0

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

*輸入描述:字串(設為多組輸入)

*程式輸出:指定子串在乙個字串中出現的次數

*/

sqstring.h:

#include #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); //輸出串

sqstring.cpp:

#include #include "sqstring.h"

int index(sqstring s,sqstring t)

}return count;

}int main()

return 0;

}

main.cpp:

#include #include "sqstring.h"

int index(sqstring s,sqstring t)

}return count;

}int main()

return 0;

}

執行結果:

知識點總結:

串的模式匹配

心得體會:

通過此專案,我加深了對bf和kmp演算法的理解與應用,能夠開啟思維,深入思考。

第八周 專案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...