Advertisement
Mitax

Char rotation

Feb 12th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 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 _05.Char_Rotation
  8. {
  9. class ChatRotation
  10. {
  11. static void Main(string[] args)
  12. {
  13. var inputString = Console.ReadLine();
  14. var numbers = Console.ReadLine()
  15. .Split(' ')
  16. .Select(int.Parse)
  17. .ToArray();
  18.  
  19. var stringToChar = inputString.ToCharArray();
  20. var currentChar = 0;
  21.  
  22. for (int i = 0; i < stringToChar.Length; i++)
  23. {
  24. currentChar = stringToChar[i];
  25.  
  26. if (numbers[i] % 2 != 0) //add
  27. {
  28. currentChar += numbers[i];
  29. Console.Write((char)currentChar);
  30. }
  31. else //substract
  32. {
  33. currentChar -= numbers[i];
  34. Console.Write((char)currentChar);
  35. }
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement