Split to a new topic. See this link for the original topic.
NickDMax, on 11 March 2007 - 02:14 PM, said:
Well lets say we will use text graphics so our histogram looks like this:
00-09: *
10-19: **
20-29: ***
30-39: ****
40-49: *****
50-59: ****
60-69: ***
70-79: **
80-89: *
90-99: *
We will need to create an array of 10 integers (our bins).
Next loop though the data and sorting it into our bins:
Then we can make a little output function to display the histogram:
This is of course only one way to do it...
00-09: *
10-19: **
20-29: ***
30-39: ****
40-49: *****
50-59: ****
60-69: ***
70-79: **
80-89: *
90-99: *
We will need to create an array of 10 integers (our bins).
Next loop though the data and sorting it into our bins:
if (data =>0 && data <10) {bin[0]++; }
else if (data =>10 && data <20) {bin[1]++; }
else if (data =>20 && data <30) {bin[2]++; }
.
.
.
// or put it into a loop:
for (i=0; i<10;i++)
{ if ((data[j] >= 10*i) && (data[j] < 10*i+9)) {bin[i]++; } }
Then we can make a little output function to display the histogram:
cout << "00-09: ";
for (i=0;i<bin[j];i++) {cout << "*"; }
This is of course only one way to do it...
erm, how to do the bin???izzit :
int bin[10]=0;
as i going to draw a histogram for the case as attached file, which show the number of a value be generated, same way as ur teach?
This post has been edited by jimblumberg: 20 March 2012 - 07:03 AM

New Topic/Question
Reply


MultiQuote


|