首页 > > 详细

Java辅导homework 编码解码 调试存储过程、C/C++讲解

Requirement
5. Write a program which can encode and decode text messages according to the following rules:
1. Put the message in a square NxN matrix, where N is an odd integer number
2. If the matrix is not completely filled with the message characters, put signs in empty cells
3. Display the matrix contents following the spiral path starting from the central element as shown in
Fig. 1
Fig. 1. Matrix reading order
The message to encode or decode is placed in a text file, which is provided by the user. The encoded
or decoded message is appended by the program to the same file. The operating mode (encoding or
decoding) is selected by the user.
Example: “Follow the red line!”
The message contains 20 characters, so the smallest odd-order matrix which can accommodate the
message is 5x5:
Following the pattern shown in Fig. 2, the encoded message is: “edenir the !**l wFollo”
To decode the massage, it has to be placed in the matrix following the spiral pattern and then read
row by row.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!