aspire12

5.DecryptingMessage

Feb 2nd, 2020
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace _5.DecryptingMessage
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             /*You will receive a key (integer) and n characters afterward. Add the key to each of the characters and append them to a message. At the end print the message, which you decrypted. */
  11.            
  12.             int key = int.Parse(Console.ReadLine());
  13.             int lines = int.Parse(Console.ReadLine());
  14.             StringBuilder message = new StringBuilder();
  15.             for (int i = 0; i < lines; i++)
  16.             {
  17.                 char input = char.Parse(Console.ReadLine());
  18.                 message.Append((char)(input + key));
  19.             }
  20.             Console.WriteLine(message);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment