The test output results are displayed at the back of the code. Some topics do not need to be decrypted. I will post them in my space after improvement.
postscript
The translation of anon_ on the fourth floor is too poor ... it won't be posted by Ciba, will it?
I tested the course of nekitarc on the fifth floor, and the results were correct, the thinking was not clear, the formula was a headache ... and there was no limit to the parameter value interval.
Complete code:
# include & lt string & gt
# include & ltiostream & gt
Use namespace std
T cycle cycle classification {
Public:
Static string encryption (int firstRotate, int secondRotate, string message);
};
string twrotationcypher::encrypt(int first size,int firstRotate,int secondRotate,string message)
{
firstSize % = 26
firstRotate % = firstSize
second rotate % = 25-first size+ 1;
String result = message;
int len = message . length();
/*
for(int j = 0; j & ltlenj++)
result . at(I)= to lower(result . at(I))。
*/
for(int I = 0; I & ltleni++)
{
int c = message . at(I);
if(c & gt; =' a' & amp& ampc & lt= 'z') ///is a lowercase letter.
{
if(c-' a '-first size+ 1 & lt; = 0) // In the first group
{
c+= first rotate;
if(c-' a ' & gt; = first size)c-= first size;
} else {// In the second group
c+= second rotate;
if(c & gt; z’)c-=(26-first size);
}
}
result . at(I)= c;
}
Return the result;
}
void main()
{
cout & lt& lttwrotationcypher::encrypt(6,3,4," abcdef ")& lt; & ltendl
cout & lt& lttwrotationcypher::encrypt(6,3,4," ghijklmnopqrstuvwxyz ")& lt; & ltendl
Cout & lt & lttwrotationcypher:: encrypt (13,0,0, "This string will never change")<& ltendl
//Returns: "This string will not change at all"
Cout & lt & lttwrotationcypher:: encrypt (13,7,0, "Only the letters A to M in this string change")<& ltendl
//Return: "ONFY TBL FLTTLLS H to G CN TBCs STRCNA JBHNAL"
Cout & lt & lttwrotationcypher:: encrypt (9,0, 16, "j to z will change here")<& ltendl
//Returns: "z sn y vikk chamge heqe"
Cout & lt & lttwrotationcypher:: encrypt (17, 9, 5, "The quick brown fox jumps over the lazy dog")<& ltendl
//Returns: "yqniz ALCKW GSFOGT Bzehnm grnwyqn Djvumgp"
Cout & lt & lttwrotationcypher:: encrypt (3, 1, 2, "beware of strange spacing")<& ltendl
//Returns: "ybvaj qvhqt uvtbpigurbakpi"
}
Output result:
defabc
klmnopqrstuvwxyzghij
This string will not change at all.
onfy TBL flttrs h to g cn TBCs str CNA jbnal
z sn y vikk chamge heqe
yqn iz ALC kwgsf ogt bzehnm grnw yqn djvu mgp
ybvaj qwv hqt uvtbpig urbakpi
Press any key to continue.