第八周 專案4 字串加密

2021-07-07 05:50:48 字數 1610 閱讀 5995

/*

檔名稱:專案4.cbp

作 者:孫鈺坤

完成日期:2023年11月16日

版 本 號:v1.0

問題描述:乙個文字串可用事先編制好的字元對映表進行加密。例如,設字元對映表為:

abcdefghijklmnopqrstuvwxyz

ngzqtcobmuhelkpdawxfyivrsj

則字串「lao he jiao shu ju jie gou」被加密為「enp bt umnp xby uy umt opy」。

設計乙個程式,實現加密、解密演算法,將輸入的文字進行加密後輸出,然後進行解密並輸出。

輸入描述:無

程式輸出:測試資料

*/

**:

#ifndef sqstring_h_included

#define sqstring_h_included

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

#endif // sqstring_h_included

//順序串基本運算函式

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

void strcopy(sqstring &s,sqstring t) //串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...