直方图问题 [英] Histogram question

查看:74
本文介绍了直方图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致学生:



这是新任务。



Ex7垂直直方图


编写一个程序,读取文本并打印一个垂直直方图(条形图),表示文本中每个字母(AZ)的出现位置。字母(A-Z)以外的字符将被忽略。您可以假设文本中没有小写字母。



要测试的文本:




快速布朗的狐狸在懒鬼狗身上蹦蹦跳跳。这是如何测试你的直方图的一个例子


计划。你可以使用这个例子。




样品运行


*

*


* *


* * *


* * * **


* * * * ***


* * ** * * ****

* * ** * ** ****


* * *** ***** **** **


* * ***** ***** **** ***


************* *************


ABCDEFGHIJKLMNOPQRSTUVWXYZ


问题结束。




我不知道。我怎么开始?

To student:



The this the new assignment.



Ex7 VERTICAL HISTOGRAM

Write a program that reads text and prints a vertical histogram (bar graph) representing the occurrences of each letter of the alphabet (A-Z) in the text. Characters other than the letters (A-Z) are to be ignored. You can assume that no lower case letters appear in the text.



Text to be tested:



"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. THIS IS AN EXAMPLE OF HOW TO TEST YOUR HISTOGRAM

PROGRAM. YOU CAN USE THIS EXAMPLE."



Sample Run

*

*

* *

* * *

* * * **

* * * * ***

* * ** * * ****

* * ** * ** ****

* * *** ***** **** **

* * ***** ***** **** ***

**************************

ABCDEFGHIJKLMNOPQRSTUVWXYZ


End of problem.



I don''t know .How do i start?

推荐答案

首先要有2维存储每个字母表出现的数组。

根据你读取的字符增加值。

最后你需要打印它


Raghu
First have a 2 dimensional array which stores the occurances of every alphabet.
Increment the value depending on the character u read.
Finally you need to print it

Raghu


<强> @gpraghuram


二维数组没有必要,一维数组就足够了。在打印阶段也不需要2d数组。
@gpraghuram
There is no need in two-dimensional array, one-dimensional array is enough. No need in 2d array during print phase as well.


@OP:我改变了你的主题标题。下次请使用正确的标题;文章发言在这个论坛上不太受欢迎。


亲切的问候,


Jos(主持人)
@OP: I changed your thread title. Next time use a proper title please; text speak is not much appreciated in this forum.

kind regards,

Jos (moderator)


这篇关于直方图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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