第八周專案4 字串加密

2021-07-06 04:36:35 字數 1188 閱讀 2375

//標頭檔案

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

//原始檔

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

void strcopy(sqstring &s,sqstring t) //s為引用型引數

q.length=p.length;

return q;

}sqstring unencrypt(sqstring q)

p.length=q.length;

return p;

}int main()

執行結果:

學習心得:

記得當時在課後題隨意看了一下這道題就被困住了。當時就很不明白要怎麼樣建立才能實現這個演算法。通過後來的學習慢慢明白了一步一步構造應用演算法得以實現。

知識點總結:

最基礎的東西上一步一步加深運用,離不開串的基本應用。

第八周 專案4 字串加密

檔名稱 main.cpp 作者 王超 完成日期 2015年10月23日 問題描述 字串加密 include include sqstring.h sqstring a,b 用於儲存字元對映表 sqstring encrypt sqstring p q.length p.length return q...

第八周專案4 字串加密

檔名稱 h1.cpp 完成日期 2015年10月26日 版本號 vc6.0 問題描述 設計乙個程式,實現加密 解密演算法,將輸入的文字進行加密後輸出,然後進行解密並輸出。輸入描述 加密檔案 程式輸出 加密 解密的結果 include include define maxsize 100 最多的字元個...

第八周 專案4 字串加密

問題描述 乙個文字串可用事先編制好的字元對映表進行加密。例如,設字元對映表為 abcdefghijklmnopqrstuvwxyz ngzqtcobmuhelkpdawxfyivrsj 則字串 lao he jiao shu ju jie gou 被加密為 enp bt umnp xby uy um...