国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#使用二分查找法判斷指定字符的方法

2019-10-29 21:26:23
字體:
來源:轉載
供稿:網友

本文實例講述了C#使用二分查找法判斷指定字符的方法。分享給大家供大家參考,具體如下:

private int sort_init(ref string[] chars, string str) //數組初始化{  string[] temp = str.Split(' ');  //temp.  chars = new string[temp.Count()];  int ndx = 0;  int last_empty_positon = 0;  foreach (string ch in temp)  {   ndx = last_empty_positon++;   chars[ndx] = ch;   if (ndx == 0) continue;   if (ch.Length == 0) continue;   while (chars[ndx].CompareTo(chars[ndx - 1]) < 0)   {    string s = chars[ndx];    chars[ndx] = chars[ndx - 1];    chars[ndx - 1] = s;    ndx--;    if (ndx == 0) break;   }  }  return 1;}
private bool isTheString(string str) //判斷是否為指定字符{   int end = stopChar.Length - 1;   int begin = 0;   while (end - begin > 1)   {    int mid = (end + begin) / 2;    if (stopChar[mid].CompareTo(str) > 0)     end = mid;    else if (stopChar[mid].CompareTo(str) < 0)     begin = mid;    else     return true;   }   if (stopChar[end].CompareTo(str) == 0 || stopChar[begin].CompareTo(str) == 0)    return true;   return false;}


注:相關教程知識閱讀請移步到c#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平顶山市| 迭部县| 饶平县| 洛浦县| 临潭县| 塔河县| 桃源县| 井陉县| 桑植县| 信宜市| 长治县| 当涂县| 田阳县| 黄龙县| 巧家县| 益阳市| 休宁县| 县级市| 翁源县| 岢岚县| 新和县| 东辽县| 莱芜市| 大新县| 奉节县| 香港 | 离岛区| 盐源县| 藁城市| 馆陶县| 永和县| 新竹市| 静宁县| 高州市| 土默特右旗| 镇雄县| 长治市| 辛集市| 龙胜| 凌海市| 千阳县|