Friday, May 21, 2010

C++ histogram?

I need to create a simple histogram that cout's stars when ever there is an occurance ie:





1-5: **


6-10:


11-15:***





and so forth





I have figured out the mode, average, range and all that, I just need help couting the histogram in an efficient way.





Here is my code so far: http://www.freewebs.com/brendj/prgm.htm (Some of the libraries are not found in Visual Studios so you might have to change a few objects and libraries for it to compile)


Thanks

C++ histogram?
From what I can see you're making it more difficult for yourself than you need to. If you stuck all the user input into an int usrInputArray[MAX]; then pass that to the histogram function. Print it out like


***


****


******


**


**


***


....


Or whatever your data looks like. Is a histogram on its side still a histogram?? (I have no idea!!) But yeah, thats how I'd be doing it. I havent seen the specs or anything, but I dont think you need to use the range, average etc etc for just drawing a histogram with stars. If you still have problems feel free to email me. Good luck!!

song titles

No comments:

Post a Comment