Advertisement
skipter

C# Char Rotation, Crypted, from Symbol to ASCII

Jun 24th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _5.Char_Rotation
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var crypted = Console.ReadLine().ToCharArray();
  14.             int[] intForPosition = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  15.  
  16.             string output = string.Empty;
  17.             for (int cnt = 0; cnt < crypted.Length; cnt++)
  18.             {
  19.                 if (intForPosition[cnt] % 2 == 0)
  20.                 {
  21.                     crypted[cnt] = (char)((int)crypted[cnt] - intForPosition[cnt]);
  22.                 } else
  23.                 {
  24.                     crypted[cnt] = (char)((int)crypted[cnt] + intForPosition[cnt]);
  25.                 }
  26.             }
  27.             Console.WriteLine(String.Join("", crypted));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement