Question: Problem B: Simple Shuffle Jane Coder is working on some simple ciphers to encrypt messages that she sends to her friends. The ciphers are such


Problem B: Simple Shuffle Jane Coder is working on some simple ciphers to encrypt messages that she sends to her friends. The ciphers are such that they are easy to do manually, but should also like to have a program to quickly cipher the messages. She calls one of those ciphers the Simple Shuffle, and it works like this: For each line of text you first pick first, third, fifth, and so on, every second character, and write them down. Then you write a space, and then you write the remaining characters in the line. So, for example, if a line contains the characters 12345678, then the encrypted, output line would be '1357 2468'. Your task is to help Jane by writing a program to do this. Input The input is a textual file, in which each line is not longer than 100 characters. There could be some empty lines. Ouuput For each input line your program must produce one output line according to the Simple Shuffle cipher. The newline character at the end of input line should be ignored in the cipher, and you need to print it after the encrypted line. Take a look at the sample output: you can notice that an empty line will be processed into one space, and take look also at what happens with lines with just one or two characters. Some Hints You will probably want to first read and store each input line before printing it out. You can use getchar to read line character by character, or use the C function fgets (remember that gets is not recommended). For example, you could use the following declaration and loop to read lines: char line [102] while (NULL != fgets (line, 102, stdin)) { The reason we use a line of 102 characters is to have a space for the null 10) character, and it may not be clear if the newline character is included in the specified limit of 100 characters per line, so we make one more space just in case. In the above code fgets will read at most 101 characters and append the null ( 0) character. It will stop after reading a newline character or reaching EOF The function returns 1line or NULL if an error occured or nothing is read and EOF is encountered
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
