Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Encryptt
- {
- private static void Main()
- {
- string command = Console.ReadLine();
- string input;
- string[] msg = new string[100];
- int counter = 0;
- int a = 0;
- while (msg[counter] != "END" && msg[counter] != "end")
- {
- if (command != "START" && command != "start")
- {
- break;
- }
- else if (command == "START" || command == "start")
- {
- a++;
- counter++;
- input = Console.ReadLine(); // take a string example "abcd"
- char[] msg1 = input.ToCharArray(); // example "[0]a, [1]b, [2]c, [3]d" type CHAR
- if (input != "END" && input != "end")
- {
- for (int i = 0; i < msg1.Length; i++)
- {
- if (msg1[i] >= 'a' && msg1[i] <= 'm')
- {
- msg1[i] = (char)(msg1[i] + 13);
- }
- else if (msg1[i] >= 'n' && msg1[i] <= 'z')
- {
- msg1[i] = (char)(msg1[i] - 13);
- }
- else if (msg1[i] >= 'A' && msg1[i] <= 'M')
- {
- msg1[i] = (char)(msg1[i] + 13);
- }
- else if (msg1[i] >= 'N' && msg1[i] <= 'Z')
- {
- msg1[i] = (char)(msg1[i] - 13);
- }
- if (msg1[i] == ' ')
- {
- msg1[i] = '+';
- }
- else if (msg1[i] == ',')
- {
- msg1[i] = '%';
- }
- else if (msg1[i] == '.')
- {
- msg1[i] = '&';
- }
- else if (msg1[i] == '?')
- {
- msg1[i] = '#';
- }
- else if (msg1[i] == '!')
- {
- msg1[i] = '$';
- }
- else if (msg1[i] == '+')
- {
- msg1[i] = ' ';
- }
- else if (msg1[i] == '%')
- {
- msg1[i] = ',';
- }
- else if (msg1[i] == '&')
- {
- msg1[i] = '.';
- }
- else if (msg1[i] == '#')
- {
- msg1[i] = '?';
- }
- else if (msg1[i] == '$')
- {
- msg1[i] = '!';
- }
- }
- Array.Reverse(msg1);
- }
- string m = new string(msg1); // example "[0]a, [1]b, [2]c, [3]d" type CHAR turns into "abcd" type STRING
- msg[counter] = m; // --||--
- if ((string.IsNullOrEmpty(msg[counter])))
- {
- a--;
- }
- }
- }
- int count = 0;
- int count1 = 0;
- for (int i = 0; i < msg.Length; i++)
- {
- if ((string.IsNullOrEmpty(msg[i])))
- {
- count1++;
- }
- else
- {
- if (msg[i] != "END" && msg[i] != "end")
- {
- count++;
- }
- }
- }
- if (count1 + 1 == 100)
- {
- Console.WriteLine("No messages sent.");
- }
- else
- {
- Console.WriteLine("Total number of messages: {0}", count);
- }
- for (int i = 0; i < msg.Length; i++)
- {
- if ((string.IsNullOrEmpty(msg[i])))
- {
- }
- else
- {
- if(msg[i] != "END" && msg[i] != "end")
- {
- Console.WriteLine(msg[i]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement