Home > Back-end >  [Error] expected primary - expression before '] 'token appear such mistakes? Why
[Error] expected primary - expression before '] 'token appear such mistakes? Why

Time:09-23

# include "findAlgorithm. H"
The template & lt; Typename Keytype>
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Normal lookup normal_find (array name, finding objects)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Int FindAlgorithm : : normal_find (Keytype key [], Keytype find_obj)
{
Int length_of_key=sizeof (key);
int i;
for( i=0; iIf (key [I]==find_obj)
Return the I + 1;
return -1;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Binary search half_find (array name, finding objects, starting position, the end position, lifting sequence)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
The template & lt; Typename Keytype>
Int FindAlgorithm : : half_find (Keytype key [], Keytype find_obj, int head, int the end, int rise_or_descend)
{
If (head> End)
return -1;
Else if (key [+ end (head)/2]==find_obj)
Return (head + end)/2;
Else if (key [+ end (head)/2] & gt; Find_obj)
{
If (rise_or_descend==1)
Half_find (key [], find_obj, head, head + end)/2-1, 1);
The else
Find_obj half_find (key [], (head + end)/2 + 1, end, 2);
}
The else
{
If (rise_or_descend==1)
Find_obj half_find (key [], (head + end)/2 + 1, end, 1);
The else
Half_find (key [], find_obj, head, head + end)/2-1, 2);
}
  • Related