相关疑难解决方法(0)

How to count the number of distinct of Values in a C++ `Map<Key,Values>`

I have a c++ map declared as follows

std::map<std::string, int> wordMap= {
    { "is", 6 },
    { "the", 5 },
    { "hat", 9 },
    { "at", 6 } 
    };
Run Code Online (Sandbox Code Playgroud)

I would like to know how to find the number of distinct values of int existing in wordMap. In this example, I would expect an output of 3 as i have 3 different distinct values (6,5,9).

c++

3
推荐指数
1
解决办法
116
查看次数

标签 统计

c++ ×1