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

  • 相关阅读:
    【Redis】跳跃表原理分析与基本代码实现(java)
    小鹤音形指引
    Maven
    算法思维(长期更)
    多路平衡树之红黑树
    多路平衡树之B树
    多路平衡树之2-3查找树
    栈与队列
    树基本概念
    Vue学习
  • 原文地址:https://www.cnblogs.com/guozhe/p/2397957.html
Copyright © 2011-2022 走看看