List 集合 一行4个排序
List<string> list = new List<string>(); for (int i = 0; i < 101; i++) { list.Add(i.ToString()); } int j; if (list.Count % 4 == 0) j = list.Count / 4; else j = (list.Count / 4) + 1; for (int z = 1; z <= j; z++) { //z*4-4,z*4-3,z*4-2,z*4-1 <= list.count if (z * 4 <= list.Count) { for (int k = z * 4 - 4; k <= z * 4 - 1; k++) { Console.Write(list[k] + " "); } Console.WriteLine("</ br>"); } else { int zz = z * 4 - list.Count; for (int k = z * 4 - 4; k < z * 4 - zz; k++) { Console.Write(list[k] + " "); } Console.WriteLine("</ br>"); } }
You are never too old to set another goal or to dream a new dream!!!