Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 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 ConsoleApp1
  8. {
  9. class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13. init();
  14.  
  15.  
  16. }
  17.  
  18. public static void init()
  19. {
  20. int[] p;
  21. int[,] W; //DISDIASTATOS PINAKAS
  22. int epilogi;
  23. p = Input(); // p[4,6]
  24. W = Gemisma(p[0], p[1]);
  25. epilogi = InputMenou(Menou());
  26.  
  27. if(epilogi == 1)
  28. {
  29. W = AristeriDiagonios(W);
  30. }
  31. else if (epilogi ==2)
  32. {
  33. W = DeksiaDiagonios(W);
  34. }
  35.  
  36. else if (epilogi == 3)
  37. {
  38. W = AllagiGrammis(W);
  39. }
  40. else if (epilogi == 4)
  41. {
  42. W = AllagiStilis(W);
  43. }
  44.  
  45.  
  46.  
  47.  
  48. OutPut(W);
  49.  
  50.  
  51. }
  52.  
  53.  
  54. public static int[] Input()
  55. {
  56.  
  57. int[] p = new int[2];
  58.  
  59. Console.WriteLine("Dose arithmo grammon");
  60. p[0] = Convert.ToInt32(Console.ReadLine()); //grammes
  61. Console.WriteLine("Dose arithmo katheton");
  62. p[1] = Convert.ToInt32(Console.ReadLine()); //stiles
  63.  
  64. return p;
  65. }
  66.  
  67.  
  68. public static int[,] Gemisma(int row, int col)
  69. {
  70. int[,] p = new int[row, col];
  71.  
  72. for (int i = 0; i < p.GetLength(0); i++)
  73. {
  74. for (int j = 0; j < p.GetLength(1); j++)
  75. {
  76. p[i, j] = 0;
  77. }
  78. }
  79.  
  80. return p;
  81.  
  82. }
  83.  
  84.  
  85. public static int Menou()
  86. {
  87.  
  88.  
  89. Console.WriteLine("1- Aristeri Diagonios");
  90. Console.WriteLine("2- Deksia Diagonios");
  91. Console.WriteLine("3- Grammi");
  92. Console.WriteLine("4- Stilli");
  93.  
  94. return 4;
  95. }
  96. public static int InputMenou(int a)
  97. {
  98. int epilogi;
  99. Console.WriteLine("Epelekse anamesa stis {0} katigories", a);
  100. epilogi = Convert.ToInt32(Console.ReadLine()); //epelekse o xristis
  101. return epilogi;
  102. }
  103.  
  104.  
  105.  
  106.  
  107.  
  108. public static int[,] AristeriDiagonios(int[,] p)
  109. {
  110. for (int i = 0; i < p.GetLength(0); i++)
  111. {
  112. for (int j = 0; j < p.GetLength(1); j++)
  113. {
  114. if(i==j)
  115. {
  116. p[i, j] = 1;
  117. }
  118.  
  119. }
  120. }
  121.  
  122. return p;
  123. }
  124. public static int[,] DeksiaDiagonios(int[,] p)
  125. {
  126. for (int i = 0; i < p.GetLength(0); i++)
  127. {
  128. for (int j = 0; j < p.GetLength(1); j++)
  129. {
  130. if ((i+j) == p.GetLength(0)-1)
  131. {
  132. p[i, j] = 1;
  133. }
  134. }
  135. }
  136. return p;
  137. }
  138. public static int[,] AllagiGrammis(int[,] p)
  139. {
  140. for (int i = 0; i < p.GetLength(0); i++)
  141. {
  142. for (int j = 0; j < p.GetLength(1); j++)
  143. {
  144. if (i == 0)
  145. {
  146. p[i, j] = 1;
  147. }
  148. }
  149. }
  150. return p;
  151. }
  152. public static int[,] AllagiStilis(int[,] p)
  153. {
  154. for (int i = 0; i < p.GetLength(0); i++)
  155. {
  156. for (int j = 0; j < p.GetLength(1); j++)
  157. {
  158. if (j ==0)
  159. {
  160. p[i, j] = 1;
  161. }
  162. }
  163. }
  164. return p;
  165. }
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. public static void OutPut(int[,] p)
  175. {
  176. for (int i = 0; i < p.GetLength(0); i++)
  177. {
  178. for (int j = 0; j < p.GetLength(1); j++)
  179. {
  180. Console.Write("{0,2}", p[i, j]);
  181.  
  182. }
  183. Console.WriteLine();
  184. }
  185. }
  186. }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement