using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 随机生成器2
{
class Program
{
static void GUI()
{
Console.WriteLine("*********************************");
Console.WriteLine("**** 欢迎使用整数随机数生成器 ***");
Console.WriteLine("*********************************");
}
static void Main(string[] args)//随机数的生成
{
int a, b;
int time, i;
Random r = new Random();
GUI();
Console.WriteLine("请输入您要生成的随机输的范围!");
Console.Write("生成的数大于或等于:");
do
{
try
{
a = Convert.ToInt32(Console.ReadLine());
break;//add this
}
catch
{
Console.WriteLine("您输入的数字有错误,请重新输入");
}
} while (true);
Console.Write("生成的数小于:");
do
{
try
{
b = Convert.ToInt32(Console.ReadLine());
break;//add this
}
catch
{
Console.WriteLine("您输入的数字有错误,请重新输入");
}
} while (true);
Console.Write("输出的数的个数:");
do
{
try
{
time = Convert.ToInt32(Console.ReadLine());
break;//add this
}
catch
{
Console.WriteLine("您输入的数字有错误,请重新输入");
}
} while (true);
for (i = 0; i < time; i++)
{
int temp, number = 0;
temp = r.Next(a, b);
Console.Write(temp);//add this
Console.Write('\t');
number++;
if (number % 8 == 0)
Console.WriteLine();
}
//运行环境为vs2010
Console.ReadLine();
}
}
}
|