一个文本中的单词数量 [英] Number of word in one text
本文介绍了一个文本中的单词数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试用一个程序来计算文本中的单词数,并显示每行的单词平均值。如何计算空格数并输入?在文本中?
谢谢
Hi,
I''m trying to do a program to count the number of words in a text, and show the average of words per line. How can I count the number of spaces and "enters" in a text?
Thanks
推荐答案
忘记计算空间;你知道如何找到空格并输入(即换行符,''\ n'')?如果您知道如何搜索这些,那么计算很简单。
Forget about counting the spaces; do you know how to find spaces and enters (i.e. newline characters, ''\n'')? If you know how to search for these, then counting is simple.
Ganon11,
我不知道如何使用它。我该如何使用它?
Ganon11,
I don''t know how to use this. How can I use this?
忘记计算空间;你知道如何找到空格并输入(即换行符,''\ n'')?如果您知道如何搜索这些,那么计数很简单。
Forget about counting the spaces; do you know how to find spaces and enters (i.e. newline characters, ''\n'')? If you know how to search for these, then counting is simple.
您是否知道如何从文件中获取输入,一次一行?如果是这样,那么你知道如何使用字符串类的find()方法吗?如果是这样,那么您将获得所需的所有信息。
Do you know how to get input from the file, one whole line at a time? If so, then do you know how to use the find() method of the string class? If so, then you have all the information you need.
这篇关于一个文本中的单词数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文