Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 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 ConsoleApplication5
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int wymiar = 5;
  14. int[,] tablica = new int[wymiar, wymiar];
  15.  
  16. Random rnd = new Random();
  17.  
  18. for (int i = 0; i < wymiar; i++) {
  19.  
  20. for (int j = 0; j < wymiar; j++) {
  21.  
  22. tablica[i, j] = rnd.Next(0, 2);
  23. Console.Write(tablica[i, j] + ",");
  24. }
  25.  
  26. Console.WriteLine("\n");
  27. }
  28.  
  29. int wymiar_udzialu = wymiar*2;
  30. int[,] tablica_udziału_1 = new int[wymiar_udzialu, wymiar_udzialu];
  31.  
  32.  
  33. int triger_j = 0;
  34. int triger_i = 0;
  35.  
  36. int licznik_i = 0;
  37. int licznik_j = 0;
  38.  
  39.  
  40. for (int i = 0; i < wymiar_udzialu; i++)
  41. {
  42.  
  43. for (int j = 0; j < wymiar_udzialu; j++)
  44. {
  45. if (triger_j == 2)
  46. {
  47.  
  48.  
  49.  
  50.  
  51.  
  52. triger_j = 0;
  53.  
  54. Console.Write(",");
  55.  
  56.  
  57. }
  58.  
  59. triger_j++;
  60.  
  61. tablica_udziału_1[i, j] = rnd.Next(0, 2);
  62. Console.Write(tablica_udziału_1[i, j]);
  63.  
  64. }
  65. triger_j = 0;
  66.  
  67. Console.Write("\n");
  68. }
  69.  
  70. int[,] tablica_udziału_2 = new int[wymiar_udzialu, wymiar_udzialu];
  71.  
  72. Console.Write("\n\n");
  73.  
  74. triger_j = 0;
  75. triger_i = 0;
  76.  
  77. licznik_i = 0;
  78. licznik_j = 0;
  79.  
  80. for (int i = 0; i < wymiar_udzialu; i++) {
  81.  
  82. for (int j = 0; j < wymiar_udzialu; j++) {
  83.  
  84. if (triger_j == 2) {
  85.  
  86.  
  87.  
  88. licznik_j++;
  89.  
  90. triger_j = 0;
  91.  
  92. Console.Write(",");
  93.  
  94.  
  95. }
  96.  
  97. if (tablica[licznik_i, licznik_j] == 0) {
  98.  
  99. if (tablica_udziału_1[i, j] == 1)
  100. {
  101.  
  102. tablica_udziału_2[i, j] = 1;
  103. }
  104. else
  105. {
  106.  
  107. tablica_udziału_2[i, j] = 0;
  108. }
  109. }
  110.  
  111. if (tablica[licznik_i, licznik_j] == 1)
  112. {
  113.  
  114. if (tablica_udziału_1[i, j] == 1)
  115. {
  116.  
  117. tablica_udziału_2[i, j] = 0;
  118. }
  119. else
  120. {
  121.  
  122. tablica_udziału_2[i, j] = 1;
  123. }
  124. }
  125.  
  126. triger_j++;
  127.  
  128.  
  129.  
  130. Console.Write(tablica_udziału_2[i, j]);
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. }
  140.  
  141. Console.Write("\n");
  142.  
  143. if (triger_i == 2)
  144. {
  145.  
  146.  
  147.  
  148. licznik_i++;
  149.  
  150. triger_i = 0;
  151.  
  152.  
  153. }
  154.  
  155. triger_i++;
  156.  
  157. triger_j = 0;
  158.  
  159. licznik_j = 0;
  160. }
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172. }
  173. }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement