zoukankan      html  css  js  c++  java
  • 删除数组中的重复元素

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication3
    {
        class Program
        {
            static void Main(string[] args)
            {
                string[] s = new string[10] { "11", "12", "13", "14", "15", "11", "12", "11", "13", "15" };
                List<string> sList = new List<string>();
                sList.AddRange(s);
                GetNo(0, sList);
            }
            public static  void  GetNo(int index, List<string> numList)
            {
                for (int i = index + 1; i < numList.Count; i++)
                {
                    if (numList[index].CompareTo(numList[i]) == 0)
                    {
                        numList.RemoveAt(i);
                    }
                }

                if (index < numList.Count)
                {
                    index++;
                    GetNo(index, numList);
                }
                else {
                    foreach (string item in numList)
                    {
                        Console.WriteLine(item);
                    }
                }
              
            }
        }
    }

  • 相关阅读:
    maven POM.xml 标签详解
    Spring Boot Starter 的基本封装
    谷歌浏览器屏蔽广告的插件
    关于mysql中触发器old和new
    centos7 安装zookeeper3.4.8集群
    Flink架构、原理与部署测试
    图解Spark API
    汇编器构造
    Oracle11g CentOS7安装记录
    如何创造一门编程语言?
  • 原文地址:https://www.cnblogs.com/guozhe/p/2397957.html
Copyright © 2011-2022 走看看