Advertisement
Fundamentalen

RandomNumbersInGivenRange

Mar 25th, 2014
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2.  
  3. class RandomNumbersInGivenRange
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("n = ");
  8.         int n = int.Parse(Console.ReadLine());
  9.         Console.Write("min = ");
  10.         int min = int.Parse(Console.ReadLine());
  11.         Console.Write("max = ");
  12.         int max = int.Parse(Console.ReadLine());
  13.  
  14.         if (min <= max)
  15.         {
  16.             Random random = new Random();
  17.  
  18.             for (int i = 0; i < n; i++)
  19.             {
  20.                 Console.Write(random.Next(min, max + 1) + " ");
  21.             }
  22.  
  23.             Console.WriteLine();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement