Guest User

Untitled

a guest
Nov 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 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 Input
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int step, word;
  14. string text, key, result = string.Empty;
  15.  
  16. Console.Write("Enter Text : ");
  17. text = Console.ReadLine();
  18. Console.Write("Enter Key : ");
  19. key = Console.ReadLine();
  20. Console.Write("Enter Step : ");
  21. step = int.Parse(Console.ReadLine());
  22.  
  23. // MIX STRING
  24. word = 0;
  25.  
  26. if (step <= text.Length)
  27. {
  28. for (int i = 0; i < key.Length; i++)
  29. {
  30. result += key.Substring(i, 1);
  31. for (int k = 0; k < step; k++)
  32. {
  33. try
  34. {
  35. result += text.Substring(word, 1);
  36. word++;
  37. }
  38. catch
  39. {
  40. break;
  41. }
  42. }
  43. }
  44.  
  45. if (word < text.Length)
  46. {
  47. result += text.Substring(word, (text.Length - word));
  48. }
  49. }
  50.  
  51. Console.WriteLine("Result Text : " + result);
  52.  
  53. // DECIPHER STRING
  54.  
  55. Console.WriteLine("text: " + text);
  56. Console.WriteLine("key: " + key);
  57.  
  58. Console.ReadKey();
  59. }
  60. }
  61. }
Add Comment
Please, Sign In to add comment