Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Online C# Editor for free
- // Write, Edit and Run your C# code using C# Online Compiler
- using System;
- public class ArrayXY
- {
- public static void Main(string[] args)
- {
- Random rando = new Random();
- int[,] array = new int[6, 6];
- // Выводим и Заполняем массив 0 и 1
- for (int y = 0; y < 6; y++)
- {
- for (int x = 0; x < 6; x++)
- {
- array[x, y] = rando.Next(0, 2);
- Console.Write(array[x, y] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- Console.WriteLine();
- // Выводим и Заполняем массив 0 и только один элемент 1
- int[,] array2 = new int[6, 6];
- int i = rando.Next(0, 6);
- int j = rando.Next(0, 6);
- array2[i, j] = 1;
- for (int y = 0; y < 6; y++)
- {
- for (int x = 0; x < 6; x++)
- {
- Console.Write(array2[x, y] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement