Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Problem_12._Random_Numbers_1_N
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int[] arrA = new int[n];
- Random random = new Random();
- for (int i = 0; i <= arrA.Length - 1; i++)
- {
- int number = random.Next(1, n + 1);
- while (arrA.Any(n => n == number))
- {
- number = random.Next(1, n + 1);
- }
- arrA[i] = number;
- Console.Write(arrA[i] + " ");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement