| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 899 人关注过本帖
标题:简单的随机问题!
只看楼主 加入收藏
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
快速回复:简单的随机问题!
数据加载中...
 
   



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

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