using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace exam1
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Run run = new Run();
run.Do();
Console.WriteLine(是否要继续吗?(yn));
string cin = Console.ReadLine();
if (cin == y cin == Y)
{
continue;
}
else
{
break;
}
}
}
}
public class Run
{
const int Min32 = -2147483648;
const int Max32 = 2147483647;
public double max = 0;
public void Do()
{
Console.WriteLine(输入最小值:);
string sx = Console.ReadLine();
Console.WriteLine(输入最大值:);
string sy = Console.ReadLine();
Console.WriteLine(要产生数据个数:);
long number = long.Parse(Console.ReadLine());
if (double.Parse(sx) double.Parse(sy)) 9 - 5
{
Console.WriteLine(最小值不能大于最大值!);
}
else if (double.Parse(sx) == double.Parse(sy)) 10000-10000
{
Console.WriteLine(double.Parse(sx));
}
else
{
if (sx.IndexOf(.) 0 && sy.IndexOf(.) 0) 1000 - 100000
{
long x = long.Parse(sx);
long y = long.Parse(sy);
for (int l = 0; l number; l++)
{
Console.WriteLine(Rl(x, y));
}
}
else
{
if (sx.IndexOf(.) 0 && sy.IndexOf(.) 0) 1.3333 - 2
{
long x = long.Parse(sx.Substring(0, sx.IndexOf(.)));
long y = long.Parse(sy);
for (int i = 0; i number; i++)
{
string nn = (Rl(x, y) + Rd()).ToString();
Console.WriteLine(nn);
}
}
if (sx.IndexOf(.) 0 && sy.IndexOf(.) 0) 1 - 1.3333333 2 - 6.3333333
{
long x = long.Parse(sx) - 1;
long y = long.Parse(sy.Substring(0, sy.IndexOf(.)));
for (int i = 0; i number; i++)
{
string nn = (Rl(x, y) + Rd()).ToString();
Console.WriteLine(nn);
}
}
if (sx.IndexOf(.) 0 && sy.IndexOf(.) 0) 2.3333333 - 3.3333333 5.66666 - 6.9999999
{
long x = long.Parse(sx.Substring(0, sx.IndexOf(.)));
long y = long.Parse(sy.Substring(0, sy.IndexOf(.)));
long dx = long.Parse(sx.Substring(sx.IndexOf(.) + 1, sx.Length - sx.IndexOf(.) - 1));
long dy = long.Parse(sy.Substring(sy.IndexOf(.) + 1, sy.Length - sy.IndexOf(.) - 1));
if (dx = dy) 0.66666 - 0.9999999 0.6666 - 0.6666
{
for (int i = 0; i number; i++)
{
string nn = Rl(x, y).ToString() + . + Rl(dx, dy).ToString();
Console.WriteLine(nn);
}
}
else 5.99999 - 4.33333
{
for (int i = 0; i number; i++)
{
string nn = (Rl(x, y) + Rd()).ToString();
Console.WriteLine(nn);
}
}
}
}
}
Console.ReadKey();
}
summary
int 32 随机数计算
summary
param name=x1最小值param
param name=y2最大值param
returnsreturns
public static int R(int x1, int y2)
{
Thread.Sleep(100);
Random random = new Random();
int num = random.Next(x1, y2);
return num;
}
summary
int 32 随机数计算
summary
param name=xyparam
returnsreturns
public static int R(int xy)
{
Thread.Sleep(100);
Random random = new Random();
int num = random.Next(xy);
return num;
}
public static double Rd()
{
Thread.Sleep(100);
Random random = new Random();
double num = random.NextDouble();
return num;
}
summary
int64 随机数计算
summary
param name=minparam
param name=maxparam
returnsreturns
public static long Rl(long min, long max)
{
if (Min32 = min && max = Max32)
{
max = R(int.Parse(Convert.ToString(min)), int.Parse(Convert.ToString(max)));
}
else
{
long lon = max - min;
long lon1 = lon - Max32;
lon = lon1 + R(Max32);
max = max - lon;
}
return max;
}
}
}