标题:简单的随机问题!
取消只看楼主
woshi_gaoyuan
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-7-7
 问题点数:0 回复次数:0 
简单的随机问题!
编写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();
}


}
}
搜索更多相关主题的帖子: 随机 using Random System int 
2008-07-07 20:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-222997-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.814516 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved