Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 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 EncrryptedMatrix
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. char direction = char.Parse(Console.ReadLine());
  15.  
  16. int[] arr = new int[input.Length];
  17. for (int i = 0; i < input.Length; i++)
  18. {
  19. int currInt = input[i] % 10;
  20. arr[i] = currInt;
  21. }
  22. List<int> cripted = new List<int> { };
  23. for (int i = 0; i < arr.Length; i++)
  24. {
  25. if(arr[i]%2!=0)
  26. {
  27. if(input.Length==1)
  28. {
  29. cripted.Add(arr[i]);
  30. }
  31. else if (i == 0)
  32. {
  33. cripted.Add(arr[i+1]+arr[i]);
  34. }
  35. else if(i==arr.Length-1)
  36. {
  37. cripted.Add(arr[i] + arr[i - 1]);
  38. }
  39. else
  40. {
  41. cripted.Add(arr[i] + arr[i - 1] + arr[i + 1]);
  42. }
  43. }
  44. else
  45. {
  46. cripted.Add(arr[i] * arr[i]);
  47. }
  48.  
  49. }
  50. string final="";
  51. foreach(int member in cripted)
  52. {
  53. final = final + member.ToString();
  54. }
  55. char[,] result = new char[final.Length, final.Length];
  56. if(direction=='/')
  57. {
  58. for (int i = final.Length-1,counter=0; i >= 0; i--)
  59. {
  60. for (int j = 0; j < final.Length; j++)
  61. {
  62. if(i!=final.Length-j-1)
  63. {
  64. result[i, j] = '0';
  65. }
  66. else
  67. {
  68. result[i, j] = final[counter];
  69. }
  70. }
  71. counter++;
  72. }
  73. }
  74. else
  75. {
  76. for (int i = 0; i < final.Length; i++)
  77. {
  78. for (int j = 0; j < final.Length; j++)
  79. {
  80. if(i!=j)
  81. {
  82. result[i, j] = '0';
  83. }
  84. else
  85. {
  86. result[i, j] = final[i];
  87. }
  88. }
  89. }
  90. }
  91. for (int i = 0; i < final.Length; i++)
  92. {
  93. for (int j = 0; j < final.Length; j++)
  94. {
  95. Console.Write(result[i, j] + " ");
  96. }
  97. Console.WriteLine();
  98. }
  99.  
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement