定义了一个 map<int, int> mp,mp 里边所有key对应的value都为1。
map<int, int> mp
现在要判断一个变量 tmp 在不在 mp 里边。 为什么把 if( mp[tmp] ) 改为 if( mp.find(tmp)!=mp.end() ) 之后答案输出不一样了?
if( mp[tmp] )
if( mp.find(tmp)!=mp.end() )