简单的随机问题!
编写myrandom类 要求:实现取minValue到maxValue之间的随机数,要求是size个!
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary1
{
public class myrandom
{
int size, maxValue, minValue;
int[] num;
public myrandom(int size, int maxValue, int minValue)
{
size=this.size;
maxValue = this.maxValue;
minValue = this.minValue;
}
private void setrandom()
{
int total=0;
bool flag=true;
int[] temp = new int[size];
Random rnd=new Random();
while(flag)
{
if(total<size)
{
for (int i = 0; i <size; i++)
{
temp[i] = rnd.Next(minValue, maxValue);
for(int a=0;a<total;a++)
if(temp[i]!=num[a])
num[total]=temp[i];
}
total++;
}
else
{
flag = false;
}
}
}
public void getrandom()
{
setrandom();
}
}
}[Discuz!]&Menu=yes" target="_blank">" border="0">