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

  • 相关阅读:
    1. 马尔科夫决策过程
    梯度下降法、随机梯度下降法、小批量梯度下降法
    计算曲线与坐标轴的面积
    鼠标进入,显示div
    codewar
    Django firstDay
    C#学习之关于lock
    winfrom 界面中表格数据修改及刷新(DEV)
    SVN 分支合并 版本控制
    wpf 绑定非元素对象
  • 原文地址:https://www.cnblogs.com/guozhe/p/2397957.html
Copyright © 2011-2022 走看看