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

  • 相关阅读:
    Mybatis一级缓存和二级缓存总结
    UML模型的基本概念
    Proxy patten 代理模式
    UML 基础:类图
    Java与UML交互图
    Composite Pattern (组合模式)
    用例建模指南
    Prototype Pattern(原型模式)
    Adapter Pattern(适配器模式)
    UML 类与类之间的关系
  • 原文地址:https://www.cnblogs.com/guozhe/p/2397957.html
Copyright © 2011-2022 走看看