I am trying to generate five sets of a random number in c# order by highest number and comma-separated
I tried using
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
//Your code goes here
//Console.WriteLine("Hello, world!");
int[] randNumber = new int[5];
Random rand = new Random();
Console.Write("The random numbers are: ");
for (int h = 0; h < randNumber.Length; h++)
{
randNumber[h] = rand.Next(1, 20);
}
Console.Write(string.Join(", ", randNumber));
}
}
}
I am getting output only of one set without sorting(Highest to lowest) i.e.
The random numbers are: 12, 2, 12, 19, 11
The Expected Output should be like this::
- 11,9,7,6,4
- 13,8,7,6,4
- 13,9,7,6,2
- 17.9,7,6,1
- 1,6,7,4,14
Aucun commentaire:
Enregistrer un commentaire