This article illustrates how C # uses the binary lookup method to judge the specified characters. Share to everyone for your reference, specific as follows:
private int Sort_init (ref string[] chars, string str)//array initialization
{
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)//judge whether the specified character
{
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;
}
Read more about C # Interested readers can view the site topics: "C # XML file Operation Tips Summary", "C # Common control usage Tutorial", "WinForm Control Usage Summary", "C # Data structure and algorithm tutorial", "C # object-oriented Program design Introductory Course" and "C # A summary of thread usage tips for programming
I hope this article will help you with C # programming.