第八周專案1 建立順序串演算法庫

2021-07-24 07:43:42 字數 1980 閱讀 8459

問題及描述:

[cpp]view plain

copy

//1.標頭檔案sqstring.h中定義資料結構並宣告用於完成基本運算的函式。

#ifndef sqq_h_included

#define sqq_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);

//判串相等

intstrlength(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 //sqq_h_included

[cpp]view plain

copy

//2.在sqstring.cpp中實現這些函式

#include 

#include 

#include "sqstring.h"

void

strassign(sqstring &s,

char

cstr) 

//s為引用型引數

void

strcopy(sqstring &s,sqstring t)    

//s為引用型引數

bool

strequal(sqstring s,sqstring t)  

return

same;  

}  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)  

}[cpp]view plain

copy

//3.在main函式中完成測試

#include 

#include "sqstring.h"

intmain()    

運算結果:

第八周專案1建立演算法庫順序串

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

第八周專案1 建立順序串演算法庫

檔名稱 shunxuchuan.cpp 完成日期 2015年10月30日 版本號 vc 6.0 問題描述 建立順序串演算法庫 輸入描述 無 程式輸出 子串,串連線,串刪除,串插入等 ifndef head h included define head h included include inclu...

第八周專案1 建立順序串演算法庫

問題及 檔名稱 專案1.cbp 作 者 董雪 完成日期 2016年10月20日 版 本 號 v1.0 問題描述 定義順序串的儲存結構,實現其基本運算,並完成測試。輸入描述 無 程式輸出 測試資料 1.標頭檔案sqstring.h ifndef sqstring h included define s...