// Design a program and input several strings from the keyboard
// Use the search function in the algorithm library to search for the specified string
// Output the search result
# Include <iostream>
# Include <string>
# Include <vector> // contains the container
# Include <iterator> // contains the input/output iterator.
# Include <algorithm> // contains the algorithm library header file
Using namespace STD;
Void main ()
{
Vector <string> VEC (10); // create the object VEC of the string type vector container with 10 elements
Typedef ostream_iterator <string> output; // define ostream_iterator as output
Cout <"Enter several strings and end with-1 :";
// Input string
Int I;
For (I = 0; I <Vec. Size (); I ++)
{
Cin> VEC [I];
If (VEC [I] = "-1 ")
Break;
}
Cout <"input" <I <"strings :";
Copy (VEC. Begin (), VEC. Begin () + I, output (cout ,""));
Cout <Endl;
// Search for strings
String STR;
Cout <"Enter the string to be searched :";
Cin> STR;
Vector <string >:: iterator it;
It = find (VEC. Begin (), VEC. End (), STR );
If (it! = Vec. End ())
Cout <"this string exists! "<Endl;
Else
Cout <"this string does not exist! "<Endl;
}