统一归档20260319
This commit is contained in:
29
CS/lab10/10_2/Program.cs
Normal file
29
CS/lab10/10_2/Program.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace _10_2
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
ArrayList redballs = new ArrayList() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 };
|
||||
ArrayList blueballs = new ArrayList() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
ArrayList redball = new ArrayList();
|
||||
Random randobj = new Random();
|
||||
int blueball=randobj.Next(1, 16);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int index = randobj.Next(0, redballs.Count);
|
||||
redball.Add(redballs[index]);
|
||||
redballs.RemoveAt(index);
|
||||
}
|
||||
Console.WriteLine("Red Balls:");
|
||||
foreach (var item in redball)
|
||||
{
|
||||
Console.Write(item + " ");
|
||||
}
|
||||
Console.WriteLine("\nBlue Ball:");
|
||||
Console.WriteLine(blueball);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user