【笔记】常用算法

检查List列表中的重复项

思路是先把第一个数字依次与后面所有数字比较,然后把第二数字一次与后面所有数字比较。。。

 var tempList = new string[]{ "1","2", "3", "4", "5", "4", "6" };

 for (int i = 0; i < tempList.Length; i++)
 {
     for (int j = i + 1; j < tempList.Length; j++)
     {
         if (tempList[i].Equals(tempList[j]))
         {
             MessageBox.Show("检测到有重复的数字 = " + tempList[i]);
             return;
         }
     }
 }

快速排序

http://ahalei.blog.51cto.com/4767671/1365285

原文地址:https://www.cnblogs.com/guxin/p/common-algorithm.html