zoukankan      html  css  js  c++  java
  • 产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace 测试
    {
        class Program
        {
            static void Main(string[] args)
            {
                List<int>arr=new List<int>();
                int[]newArr=new int[100];
                for (int i = 1; i <= 100; i++)
                {
                    arr.Add(i);
                }
                for (int p = 0; p < 100; p++)
                {
                    Random random=new Random();
                    int j = random.Next(0, arr.Count);
                    newArr[p] = arr[j];
                    arr.RemoveAt(j);
                }
                foreach (int i in newArr)
                {
                    Console.WriteLine(i);
                }
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    vue CDN seting
    AutoMapper
    c# list<class> to datatable
    vue watch
    net core 3.1 open file
    net core 3.1 area Global
    net core 3.1 area
    ef core log
    3.1 ef core
    3.1 daper
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3250244.html
Copyright © 2011-2022 走看看