手机
当前位置:查字典教程网 >编程开发 >C#教程 >向一个数组中插入一个1~100的随机数
向一个数组中插入一个1~100的随机数
摘要:namespaceConsoleApplication2{classProgram{staticvoidMain(string[]args)...

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(); } } }

【向一个数组中插入一个1~100的随机数】相关文章:

基于使用递归推算指定位数的斐波那契数列值的解决方法

两路归并的数组与链表的实现方法

c#中虚函数的相关使用方法

用C#生成不重复的随机数的代码

C#中怎么将一个List转换为只读的

C# 16进制与字符串、字节数组之间的转换

深入理解C#索引器(一种支持参数的属性)与属性的对比

C#.NET字符串比较中忽略符号的方法

c# 方法可变数量的参数

c#中判断字符串是不是数字或字母的方法

精品推荐
分类导航