Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace encription
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string cypher = string.Empty;
- for (int i = 0; i < n; i++)
- {
- char letter = char.Parse(Console.ReadLine());
- cypher+=Encrypt(letter);
- }
- Console.WriteLine(cypher);
- }
- static string Encrypt(char letter)
- {
- int asciiCode = letter;
- int appendFirstLast = asciiCode;
- string append = string.Empty;
- string midlle = string.Empty;
- if (asciiCode >= 100)
- {
- while (appendFirstLast > 0)
- {
- append = (appendFirstLast % 10).ToString();
- midlle = midlle.Insert(0, append);
- appendFirstLast /= 100;
- }
- }
- else if (asciiCode < 100)
- {
- while (appendFirstLast > 0)
- {
- append = (appendFirstLast % 10).ToString();
- midlle = midlle.Insert(0, append);
- appendFirstLast /= 10;
- }
- }
- int intMidlle = int.Parse(midlle);
- char start = (char)(asciiCode + (intMidlle % 10));
- char end = (char)(asciiCode - ((intMidlle / 10) % 10));
- string cypher = start + midlle + end;
- return cypher;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement