查字典(c++)

思路

  1. 判断insert和find。
  2. insert放入string set,find就用count。

过程

1. 判断insert和find

2. 放入set中

3. 判断结果

代码

#include
#include
using namespace std;
set s;
int main()
{
	string st,str;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>st>>str;
		if(st[0]=='i')
		{
			s.insert(str);
		}
		else if(s.count(str))
		{
			cout<<"yes"<

你可能感兴趣的:(c++,算法,蓝桥杯)