日期:2014-05-18 浏览次数:20790 次
var array = new string[] { "000000000000111010010101010000000000000000", "111010101000111100000000000000000110010000", "000010101010101010010000000000000000000000", "100001010100101000000000110000000010001001", "110010101010000000000000000000000000000000" }; var spa = new int[] { 0, 8, 16, 32 }; foreach (var item in array) { var index = -1; while ((index = item.IndexOf('1', index + 1)) >= 0) { for (int i = 1; i < spa.Length; i++) { if (index < spa[i]) { var r = index - spa[i - 1]; Console.WriteLine(r); break; } } } }