// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI?CMPE 1170, Spring 2009 // Lab 22: Linear search // Date: January 12, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // This lab exercise is to show how to do linear search. // // Compile and run your program. When everything is fine, // print your .cpp and .h files and turn them to me or the TA. // ***************************************************************** #include < iostream > #include #include < string > #include < cstring > #include < cmath> #include #include #include "lab_22_head.h" using namespace std; int main( ) { const int SIZE=100; //list or array size int list[SIZE]; //list or array int value; //tagert value int count; //comparisons of performance metric int pos; //position of the target if found or -1 char choice; //flag for yes or no choice //load list with random numbers loadList(list, SIZE); //show list showList(list, SIZE); //loop to play search again and again do { //get a target value cout<<"Enter a target value to for linear search: "; cin>>value; //linear search pos = linearSearch(list, value, count, SIZE); if (pos == -1) cout<< "The target "< "; cin>>choice; }while (toupper(choice) == 'Y'); /****************************************************************** This part is for you: You shall follow the above approaches to implement linear search for a list of words. That is, you need to implement the following three functions: (1) loadWordList(...) (2) linearWordSearch(...) (3) showWordList(...) and have a similar loop to test your implementation. ******************************************************************/ //well done and exit return 0; }