在段落中找到重复的单词.
问题描述:
我们有一个段落,我们想找出重复出现多少次的单词.这给了
输出单词,如果没有更多单词,则不输出时间")
''We have a Paragraph in which we want to find out the word which are repeat how many time.That''s give
output the word and no of time if it''s come more tha one times'')
答
Psuedocode:
声明一个动态列表.每个元素应包含一个可变长度的字符串和一个数字计数.
1.输入下一个单词
2.将其与单词列表中的每个元素进行比较(此列表最初为空)
3.如果找到,则在该元素中增加计数器
4.如果未找到,则将其添加到列表中,并在该元素中增加计数器
5.如果还有其他单词,请在步骤1重复.
6.如果没有其他单词,请扫描列表并显示单词及其计数器
Psuedocode:
Declare a dynamic list. Each element should contain a variable-length string and a numeric count.
1. Input the next word
2. Compare it with each element in the list of words (this list is initially empty)
3. If it is found, increment the counter in that element
4. If it is not found, add it to the list and increment the counter in that element
5. If more words remain, repeat at step 1.
6. If no more words remain, scan the list and display the words and their counters