编程论坛
注册
登录
编程论坛
→
C++教室
请问一下这道题目怎么做,多方查找无果,非常感谢
yegouzhifu
发布于 2010-05-23 20:33, 485 次点击
使用find泛型算法在一个list链表中查找数据
我才大一没学到C++,但我一高中同学问我了,我答应帮她查的,拜托了
3 回复
#2
yegouzhifu
2010-05-23 20:47
人工置顶啊
#3
南国利剑
2010-05-26 02:46
利用容器建立一个链表,然后就可以了啊。c++里的stl中有好多个容器哦。
要源代码的话就去百度一下!
#4
ciweitou163
2010-05-26 16:39
程序代码:
map<
string
,
int
> stringCounts;
string
str;
while
(
cin
>> str ) ++stringCounts[str];
map<
string
,
int
>::iterator iter = stringCounts.find(
"
spoon
"
);
if
( iter != stringCounts.end() ) {
cout
<<
"
You typed '
"
<< iter->first <<
"
'
"
<< iter->second <<
"
time(s)
"
<< endl;
}
When run with this input:
my spoon is too big. my spoon is TOO big! my SPOON is TOO big! I am a BANANA!…
the above code produces this output:
You typed 'spoon' 2 time(s)
1