using System; using System.Collections.Generic; class RandomizeTheNumbers1ToN { static void Main() { int n = int.Parse(Console.ReadLine()); int[] nArray; List uniquePos = new List(); nArray = new int[n]; Random randomGenerator = new Random(); for (int i = 0; i < nArray.Length; i++) { int randomIndex = randomGenerator.Next(nArray.GetLowerBound(0), nArray.GetUpperBound(0)+1); while (uniquePos.Contains(randomIndex)) //checking if the number is already printed { randomIndex = randomGenerator.Next(nArray.GetLowerBound(0), nArray.GetUpperBound(0)+1); } nArray[i] = randomIndex + 1; uniquePos.Add(randomIndex); Console.WriteLine(nArray[i]); } } }