Есть код 10 рандомных чисел с диапазоном 15. Нужно сделать так что бы при генераций этих чисел, числи не совпадали. Все числа должны быть разные, нужно сделать через цикл For Помогите а) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { Random r = new Random(); int[] array = new int[10]; for (int i = 0; i < array.Length; i++) { array[i] = r.Next(15); } for (int i = 0; i < array.Length; i++) { Console.WriteLine(array[i]); } Console.ReadKey(); } } } Код using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { Random r = new Random(); int[] array = new int[10]; for (int i = 0; i < array.Length; i++) { array[i] = r.Next(15); } for (int i = 0; i < array.Length; i++) { Console.WriteLine(array[i]); } Console.ReadKey(); } } } Только через for, if, elseif, else Помогите а(
Не ? using System; using System.Linq; using System.Collections.Generic; class Program { private static Random RND = new Random(); public static void Main() { List<int> arr = new List<int>(Enumerable.Range(10, 91)); int[,] mat = new int[10, 8]; for (int i = 0; i < mat.GetLength(0); ++i) { for (int j = 0; j < mat.GetLength(1); ++j) { int k = RND.Next(arr.Count); mat[i, j] = arr[k]; arr[k] = arr[arr.Count - 1]; arr.RemoveAt(arr.Count - 1); } } for (int i = 0; i < mat.GetLength(0); ++i) { for (int j = 0; j < mat.GetLength(1); ++j) { Console.Write($"{mat[i, j]}{j == mat.GetUpperBound(1) ? '\n' : '\t'}"); } } } } Код using System; using System.Linq; using System.Collections.Generic; class Program { private static Random RND = new Random(); public static void Main() { List<int> arr = new List<int>(Enumerable.Range(10, 91)); int[,] mat = new int[10, 8]; for (int i = 0; i < mat.GetLength(0); ++i) { for (int j = 0; j < mat.GetLength(1); ++j) { int k = RND.Next(arr.Count); mat[i, j] = arr[k]; arr[k] = arr[arr.Count - 1]; arr.RemoveAt(arr.Count - 1); } } for (int i = 0; i < mat.GetLength(0); ++i) { for (int j = 0; j < mat.GetLength(1); ++j) { Console.Write($"{mat[i, j]}{j == mat.GetUpperBound(1) ? '\n' : '\t'}"); } } } }