第八周專案4 字串加密

2021-07-23 20:54:12 字數 1490 閱讀 8141

問題及**:

/*

* 檔名稱:cube007.cpp

* 作 者:劉小楠

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

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

* 輸入描述:原文

* 輸出描述:密文及解密

*/

sqstring.h

#ifndef sqstring_h_included

#define sqstring_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); //判串相等

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

sqstring.cpp

#include #include #include "sqstring.h"

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...