Topic: C programming: classwork.
Content: classwork (only in class)
Classwork assignment (only in class)
Gentle Reminder!
You can get points only if you send us your solutions of [only-in-class] classwork assignments:
You must submit your [only-in-class] solution before the end of a lesson! The solutions, sent after that, will not be graded.
You can use any arbitrary materials, if desired, but conversations with each other are prohibited.
If conversation (incl. communication by chats, e-mail etc.) occurs the participants will get “0” (ZERO) points for this assignment.
If you are a member of plagiarists’ team, your solution can be graded as “0” (ZERO).
Name your solution file and topic of an e-mail letter as follows:
CW<a consecutive number of a lesson>_<firstname>_<lastname>_<studentID>group<group number><_><Encoding>
for example: CW15_Jane_Doe_123456MVEB21_Encoding.c
You must send your solutions to both of us:
Dr Marina Brik marina.brik@ati.ttu.ee
Dr Sergei Kostin sergei.kostin@gmail.com
Task „Encoding the text“ (2 points):
Write a program on C using a generalized (not detailed) UML diagram.
With the help of a dictionary of characters convert the initial text into an encrypted one, according to the dictionary where each character corresponds to a different character.
1. Enter an integer n, corresponding to the number of pairs of characters in a dictionary, where (0 < n <= 10)
2. Type pairs of characters to the dictionary - each pair includes an initial character and the character that replaces the initial one. Characters are separated by a space. We assume that the input pair is made correctly. Keep these pairs in two-dimensional array DICT [n] [2].
3. Type the text without whitespace characters (up to 100 characters) that must be encrypted.
4. Perform encryption (substitution characters) of initial text, storing the result in a separate string of characters in the memory.
5. Display the result on the screen.
Hint: to read two characters from a keyboard use: scanf(" %c %c", &DICT[i][0], &DICT[i][1]);
NB! There must be empty space between “ and % in scanf(" %c %c", …) to read characters correctly.
Program output:
Activity Diagram (UML):
Konstantin Shibin
Marina Brik
Sergei Kostin
Updated: 11.12.2017