1006 questions, this problem in fact, the overall is not difficult, to say that rare words do translate more difficult (may be my English is really bad), but as long as you understand the specific key words can be easily understood.
The whole meaning is probably to say that the process of encrypting and decrypting (according to the meaning of the topic), the whole test instructions means to give an intermediate value K and a string is ciphertext (the encrypted string), and then you need to follow the corresponding relationship given in the topic ("' = 0, ' A ' =1, ' b ' = 2, ..., ' Z ' = 26, '. ' =27) ciphertext corresponds to the Ciphercode (string corresponding to the number of cryptographic strings), and then by giving the formula Ciphercode[i] = (plaincode[ki mod n]-i) MoD 28,n represents the length of the cipher string. Make some transformations for plaincode[(i*k)%ciphertext.size ()] = ((ciphercode[i]+i)%28), and then use this formula to figure out the plaincode of each bit (the number string for the original text of the password). Then in the correspondence given by the topic ("' = 0, ' A ' =1, ' B ' =2, ..., ' z ' = 26, '. ') =27) came to plaintext,
Then you can output the plaintext.
And then on the code
#include <iostream> #include <string> using namespace std;
int main () {int ciphercode[1000],plaincode[1000];
string ciphertext;
Char plaintext[1000];
int k;
while (cin>>k) {if (k==0) {break;
} cin>>ciphertext;
for (int i=0;i<ciphertext.size (); i++) {if (ciphertext[i]== '. ')
{ciphercode[i]=27;
} else if (ciphertext[i]== ' _ ') {ciphercode[i]=0;
} else {ciphercode[i]=ciphertext[i]-' a ' +1; }} for (int i=0;i<ciphertext.size (); i++) {plaincode[(i*k)%ciphertext.size ()] = ((c
Iphercode[i]+i)%28);
} for (int i=0;i<ciphertext.size (); i++) {if (plaincode[i]==27) {
Plaintext[i]= '. ';
} else if (plaincode[i]==0) {plaintext[i]= ' _ ';
} else {Plaintext[i] = plaincode[i]+ ' a '-1;
}} for (int i=0;i<ciphertext.size (); i++) {cout<<plaintext[i];
} cout<<endl; }
}
Finished ~