第八周 專案二 建立鍊錶的演算法庫

2021-07-09 01:12:51 字數 2503 閱讀 7464

/*   

*檔名稱:graph.cpp

*作 者:蘇凱祺

*完成日期:2023年12月17號

*版 本 號:v1.0

*問題描述:建立鍊錶的演算法庫

*/

listring.h

#ifndef listring_h_included

#define listring_h_included

typedef struct snode

listring;

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

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

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

int strlength(listring *s); //求串長

listring *concat(listring *s,listring *t); //串連線

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

listring *insstr(listring *s,int i,listring *t) ; //串插入

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

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

void dispstr(listring *s); //輸出串

#endif // listring_h_included

listring.cpp

#include #include #include "listring.h"

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

r->next=null;

}void strcopy(listring *&s,listring *t) //串t複製給串s

r->next=null;

}bool strequal(listring *s,listring *t) //判串相等

if (p==null && q==null)

return true;

else

return false;

}int strlength(listring *s) //求串長

return i;

}listring *concat(listring *s,listring *t) //串連線

p=t->next;

while (p!=null) //將t的所有節點複製到str

r->next=null;

return str;

}listring *substr(listring *s,int i,int j) //求子串

r->next=null;

return str;

}listring *insstr(listring *s,int i,listring *t) //串插入

while (p1!=null) //將t的所有節點複製到str

while (p!=null) //將*p及其後的節點複製到str

r->next=null;

return str;

}listring *delstr(listring *s,int i,int j) //串刪去

for (k=0;knext;

while (p!=null) //將*p及其後的節點複製到str

r->next=null;

return str;

}listring *repstr(listring *s,int i,int j,listring *t) //串替換

for (k=0;knext;

while (p1!=null) //將t的所有節點複製到str

while (p!=null) //將*p及其後的節點複製到str

r->next=null;

return str;

}void dispstr(listring *s) //輸出串

printf("\n");

}main.cpp

#include #include "listring.h"

int main()

執行結果:

第八周 專案二 建立鏈串演算法庫

檔名稱 作 者 王銘澤 完成日期 2017年12月7日 版 本 號 v1.0 問題描述 建立鏈串的演算法庫 輸入描述 無 程式輸出 程式及 main.cpp include include ljj.h int main ljj.h ifndef ljj h included define ljj h...

第八周 專案二 建立鏈串的演算法庫

問題及 2015,煙台大學計算機與控制工程學院 完成日期 2015年10月19日 問題描述 定義鏈串的儲存結構,實現其基本運算,並完成測試。ifndef sqstring h included define sqstring h included typedef struct snode listr...

第八周 專案二 建立鏈串的演算法庫

檔名稱 test.cpp 完成日期 2015年10月26日 問題描述 建立鏈串的演算法庫 include include ifndef listring h included define listring h included typedef struct snode listring void ...