Advertisement
grubcho

Char rotation

Jun 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 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 Char_rotation
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             char[] chars = Console.ReadLine().ToCharArray();
  14.             string[] input = Console.ReadLine().Split(' ');
  15.             int[] numbers = new int[input.Length];
  16.             string output = string.Empty;
  17.             for (int i = 0; i < numbers.Length; i++)
  18.             {
  19.                 numbers[i] = int.Parse(input[i]);
  20.                 if (numbers[i] % 2 == 0)
  21.                 {
  22.                     int ASCIICode = chars[i];
  23.                     output += (char)(ASCIICode - numbers[i]);
  24.                 }
  25.                 else if (numbers[i] % 2 != 0)
  26.                 {
  27.                     int ASCIICode = chars[i];
  28.                     output += (char)(ASCIICode + numbers[i]);
  29.                 }
  30.             }
  31.             Console.WriteLine(output);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement