求帮我脑洞大开。
有这么一个题目。
有三种方法。
1.1)定义新的strClass类,并重载比较类的比较函数
2)使用map<strClass,int>进行统计
2.1)将所有的字符串的字母排序
2)使用map<string,int>进行统计
3.
那么有其他更有效的办法吗?
谢谢!
2018-11-12 01:28
程序代码:unsigned encode( const char* s )
{
unsigned result = 0;
for( size_t i=0; i!=5; ++i )
result |= 1u << (s[i]-'A');
return result;
}
int main( void )
{
unsigned count[252] = {};
for( 那一百万个字符串 )
++count[encode(字符串)];
}
2018-11-12 08:57
2018-11-12 12:10
2018-11-12 12:42
2018-11-12 22:01
2018-11-13 08:31
2018-11-13 17:46
2018-11-13 18:13