向一个数组中插入一个1~100的随机数
作者:whsnow 时间:2022-03-29 16:12:22
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>();
Random ran = new Random();
while(true)
{
if (list.Count >= 100)
{
break;
}
int s = ran.Next(1, 101);
if (!list.Contains(s))
{
list.Add(s);
}
}
list.Sort();
foreach (int i in list)
{
Console.Write(i + " ");
}
Console.ReadKey();
}
}
}
标签:数组,随机插入
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java编程abstract类和方法详解
2023-12-15 06:08:46
Spring中Bean的加载与SpringBoot的初始化流程详解
2022-12-18 05:02:18
![](https://img.aspxhome.com/file/2023/2/80252_0s.jpg)
Java 十大排序算法之冒泡排序刨析
2022-07-05 19:30:29
![](https://img.aspxhome.com/file/2023/4/68134_0s.png)
关于Java中的IO流总结(推荐)
2023-08-23 18:13:56
![](https://img.aspxhome.com/file/2023/1/58191_0s.jpg)
SpringBoot应用启动流程源码解析
2023-11-25 00:03:24
C#后台创建控件并获取值的方法
2022-10-20 08:39:46
Java实现滑动验证码的示例代码
2022-08-27 15:10:12
![](https://img.aspxhome.com/file/2023/0/74890_0s.jpg)
基于Jenkins搭建.NET Core持续集成环境过程图解
2021-10-25 03:44:33
![](https://img.aspxhome.com/file/2023/8/78858_0s.png)
什么是Java自旋锁
2022-09-22 22:10:55
![](https://img.aspxhome.com/file/2023/1/72301_0s.png)
SpringData JPA中@OneToMany和@ManyToOne的用法详解
2021-10-01 00:49:10
![](https://img.aspxhome.com/file/2023/5/67125_0s.png)
基于Java8实现提高Excel读写效率
2023-11-25 10:01:37
java实现的各种排序算法代码示例
2023-01-29 03:48:27
springboot docker jenkins 自动化部署并上传镜像的步骤详解
2023-07-28 01:54:38
![](https://img.aspxhome.com/file/2023/5/57915_0s.png)
Android RecyclerBarChart绘制使用教程
2023-06-19 12:18:36
![](https://img.aspxhome.com/file/2023/1/83521_0s.png)
深入理解Java中的弱引用
2023-07-19 20:14:53
Java多线程wait()和notify()方法详细图解
2021-09-19 20:27:32
![](https://img.aspxhome.com/file/2023/1/66231_0s.png)
java和javascript中过滤掉img形式的字符串不显示图片的方法
2021-08-31 10:12:49
![](https://img.aspxhome.com/file/2023/8/65738_0s.png)
SpringBoot整合RocketMQ的详细过程
2023-07-10 05:07:00
![](https://img.aspxhome.com/file/2023/6/60256_0s.jpg)
Java编程实现月食简单代码分享
2022-12-27 12:33:24
![](https://img.aspxhome.com/file/2023/3/79943_0s.png)
java int类型二维数组实现“杨辉三角”的完整实例
2022-10-05 19:31:49
![](https://img.aspxhome.com/file/2023/7/64757_0s.png)