斗地主——找出顺子的算法
1 static List<crads> shuen(List<crads> list) 2 { 3 List<crads> cList = new List<crads>(); 4 for (int i = 0; i < list.Count;++i) 5 { 6 int num = list[i].id; 7 cList.Add(list[i]); 8 for (int j = 0; j < list.Count;++j ) 9 { 10 if (list[j].id == num + 1) 11 { 12 num = list[j].id; 13 cList.Add(list[j]); 14 } 15 } 16 17 if (cList.Count >= 5) 18 { 19 20 return cList; 21 } 22 else 23 { 24 cList.Clear(); 25 } 26 27 } 28 return null; 29 30 }