如何计算文本文件中每个字符的百分比? [英] How to calculate the percentage of each character in a text file?

查看:121
本文介绍了如何计算文本文件中每个字符的百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请求帮助。有没有我们能做到的软件?

解决方案

Umesh写道:


求助。有没有我们可以做的软件?



请在发布的正文中重述您的真实问题。不要

依赖主题中的文字总是很明显。


你问的问题是:


如何计算文本文件中每个字符的百分比?


听起来像是我的作业。到目前为止你做了什么?你基本上要求在一个文件中分发字母(也许是

标点符号),可能是为了打印直方图和/或

报告此类字符出现在文件中的频率。


首先计算每个字符的数量。与

相比,您拥有的字符总数。


提示:选择一种语言并仅发布到该组。 C和C ++之间有一些

重叠,但它们实际上是不同的野兽。


我想找出a,b的百分比, c,d ..,z在文本文件中。假设

文本文件是一个故事。是否有用于此目的的软件?


在文章< 11 ****************** ****@k78g2000cwa.googlegroups .com> ;,

Umesh< fr **************** @ gmail.comwrote:
< blockquote class =post_quotes>
>我想在文本文件中找出a,b,c,d ..,z的百分比。假设文本文件是一个故事。有没有用于此目的的软件?



是的,有软件用于此目的,但不,我不能立即命名




这种程序用C(或C ++)编写是微不足道的。


关于你的规格的问题:应该是上限和下限

案例字符被视为等效?他们应该单独计算
吗?你的规范只提到了

小写字母,所以大写字母应该是无声的

被忽略了吗?


程序是否应该某种尝试确定是否是一个单词的一部分,并忽略那些不是的单词?

例如,如果有一个短语她住在36-E 9th St.",

然后应该计算'E'(36-E不是一个字),应该是'b $ b'' ''''和''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

-

没有人有权通过

要求经验证据来摧毁他人的信念。 - Ann Landers


Plese help. Is there any software by which we can do that?

解决方案

Umesh wrote:

Plese help. Is there any software by which we can do that?

Please restate your real question in the body of your posting. Don''t
rely on the text in the Subject to always be obvious.

The question you asked is:

"How to calculate the percentage of each character in a text file?"

Sounds like homework to me. What have you done so far? You are
essentially asking for a distribution of letters (and, perhaps,
punctuation) in a file, possibly in order to print a histogram and/or
report on how often such characters appears in the file.

Start by counting how many of each character you get. Compare that with
the total number of characters you have.

Hint: choose a language and post to that group only. There is some
overlap between C and C++, but they are really different beasts.


I want to find out % of a, b, c, d ..,z in a text file. Suppose that
the text file is a story. Is there any software for this purpose?


In article <11**********************@k78g2000cwa.googlegroups .com>,
Umesh <fr****************@gmail.comwrote:

>I want to find out % of a, b, c, d ..,z in a text file. Suppose that
the text file is a story. Is there any software for this purpose?

Yes, there is software for that purpose, but No, I couldn''t name
any immediately.

This sort of program is trivial to write in C (or C++).

A question about your specifications: should upper and lower
case characters be treated as equivilent? Should they be
counted individually? Your specification only mentioned the
lower case letters, so should upper case letters be silently
ignored?

Should the program make some kind of attempt to determine whether
a letter is part of a word, and ignore the ones that are not?
For example, if there is a phrase that "She lives at 36-E 9th St.",
then should the ''E'' be counted (36-E is not a word), should
the ''t'' and ''h'' of ''9th'' be counted, should the ''S'' and ''t''
of ''St.'' be counted?
--
"No one has the right to destroy another person''s belief by
demanding empirical evidence." -- Ann Landers


这篇关于如何计算文本文件中每个字符的百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆