1、顺序查找:O(n)
//1、顺序查找 int SequentialSearch(int *array, int n, int key) { int i=0; while( i < n && array[i] != key) { ++i; } if (array[i] == key) { cout<<"Find: "; cout<<i; return i; } else { cout<<"Not Find!"; return -1; } } int SequentialSearchAdvanced(int *array, int n, int key) { int i=0; while(array[i] != key) { ++i; } if (i < n) { cout<<"Find: "; cout<<i; return i; } else { cout<<"Not Find!"; return -1; } }