Plz help me how to solve CodeBreaker

Nov 8, 2014 at 11:47am
Task 1: Encode and Decode
(a) [20%] void encode(int key, char plain[], int length, char encoded[]);
This function implements the encoding scheme described earlier, using the key passed as the first
argument. It steps through the array plain[] from index 0 to index length􀀃–􀀃1, encodes each character
and places the resulting value in the corresponding element of encoded[]. The array plain[] is not
changed.
Examples:
(i)
Breaking the code
Tasks
char message[2] = {'H', 'i'};
char encoded_message[2];
encode(1, message, 2, encoded_message);
for (int i = 0; i < 2; ++i)
{
cout << encoded_message[i];
}
cout << endl;

(b) [20%] void􀀃decode(int􀀃key,􀀃char􀀃encoded[],􀀃int􀀃length,􀀃char􀀃plain[]);
This function decodes characters back to plaintext. The key passed as the first argument is the key
used to perform the original encoding. The function steps through array encoded[] from index 0 to
index length􀀃–􀀃1, decodes each character and places the resulting value in the corresponding element
of plain[]. The array encoded[] is not changed.
Examples:
(i)
Produces the output:
(ii)
char message[2] = {'H', 'i'};
char encoded_message[2];
encode(90, message, 2, encoded_message);
for (int i = 0; i < 2; ++i)
{
cout << encoded_message[i];
}
cout << endl;
Ij
"C
char message[2];
char encoded_message[2] = {'I', 'j'};
decode(1, encoded_message, 2, message);
for (int i = 0; i < 2; ++i)
{
cout << message[i];
}
cout << endl;
Hi


May I ask how i can design a function to encode and decode it? Thanks a lot!
Last edited on Nov 8, 2014 at 11:49am
Nov 8, 2014 at 1:11pm
This function implements the encoding scheme described earlier

what is the encoding scheme?
Nov 8, 2014 at 1:24pm
encoding scheme? What do you mean?
Nov 8, 2014 at 1:27pm
there are many ways to encode something
what is the way you are supposed to encode the text?
Nov 8, 2014 at 1:33pm
I want to array and function
Topic archived. No new replies allowed.