怎样用C#制作一个随机分组的程序?

来源:百度知道 编辑:UC知道 时间:2024/06/07 09:45:36
程序有以下功能:
输入6个,8个或10个 任意数字或名字
点击 按钮
随机分成3 3
4 4
5 5 的两组!!!

希望高手给个解答好吗?
是将6组,8组,或者10组 的数字或字符,随机分为
3组 3组……(共6组的)
4组 4组……(共8组的)
5组 5组……(共10组的)
这种格式的

这是控制台的代码,自己可以改成有窗体的。
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace test
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string[] d = new string[10];
int n;
Console.Write("请输入有多少个数字:");
while (true)
{
try
{
n = Convert.ToInt32(Console.ReadLine());
}
catch
{
Console.WriteLine("输入的不是数字!");
continue;
}
if (n > 10)
{
Console.WriteLine("输入的数必须小于等于10!");
con