c# - 用四个不同的数字随机填充列表
问题描述
我有一个需要以随机顺序(randomRotationVoidList)
填充四个不同数字的列表,例如. 到目前为止,我发现的所有内容都会生成一个包含一定范围内随机数的列表。(90, 180, 270, 360)
[270, 180, 180, 90, ...]
提前致谢!
解决方案
200 个号码的样本
Random _rnd = new Random();
int[] input = { 90, 180, 270, 360 }; // dictionary of available numbers
List<int> result = Enumerable.Range(0, 200).Select(x => input[_rnd.Next(0, input.Length)]).ToList();
如果数字模式固定为另一种方法x * 90
Random _rnd = new Random();
List<int> result = Enumerable.Range(0, 200).Select(x => 90 * _rnd.Next(1, 5)).ToList();
推荐阅读
- first-order-logic - 理解描述逻辑 (DL) 中概念的普遍限制
- sql - oracle - group by - 无聚合
- mysql - 在 MySQL 中创建和添加数据到文本文件时出现问题?
- mongodb - MongoDB 在一个文档中查询聚合
- firebase - 如何检查用户是否已在 Firestore 中注册?
- postgresql - 将 PostgreSQL 从 9.5 升级到更新版本并将数据库移动到不同的机器
- javascript - GoJS 显示不正确的图表类型
- python - Python 套接字客户端仅适用于一次迭代
- junit - JUnit5 对 @Before* 方法失败做出反应
- typescript - this.connection.getMetadata 不是函数