关于通用算法的简单问题
#include <iostream>
#include <vector>
#include <string>
int const LENGTH=4;
using namespace std;
int main()
{
string search_value;
string stra[ LENGTH ] = { "add", "climactic", "cling", "rediscovering"};
string strb[ LENGTH ] = { "加,加法", "adj.顶点的", "附着", "重新发现"};
vector<string> vec( stra, stra+LENGTH );
vector<string> ved( strb, strb+LENGTH );
cout << "enter search value: ";
cin >> search_value;
vector<string>::iterator presult;
presult = find( vec.begin(), vec.end(), search_value );
cout << "The value " << search_value <<" is "
<< (presult == vec.end()? "not present" : *presult)
<< endl;
return 0;
}
-------------------------当前运行结果:
$ ./wordLib
enter search value: cling
The value cling is cling
$
我想如果输入为cling,就返回 附着 ,
但不知道应该怎么改,请帮忙,