I'm trying to write a console app in visual studio 2010 that will read a set of numbers and construct a histogram that shows how many numbers are between each two numbers...if that makes sense. To clear it up, i'm looking for an output like:
0 - 10 ***
11 - 20 ****
21 - 30 **
So in that example, 3 numbers (*) have been found in the read file between 0 and 10. 4 numbers (*) have been found in the read file between 11 and 20 and so on.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Nothing so far unfortunately :/
I'm not sure how I'd load the file but am I right in thinking that an if statement would be used for displaying that stars?
Will your file be a continuous file with no returns or double spaces? Can you guarantee that? So just one continuous stream of “number space number space number space number” and so on?
If you can’t read a simple file into c++ the whole thing is a bit ambitious.
But what I would do is simply push each number into a vector as in: “vector <int> num;” and then iterate through num using 2 int variables:
This is non-tested pseudo code just typed into the box here…. Also, in order to create the vector I would need to have the answers to my first questions regarding the file format.
Oh GCDEF…. Seriously! Is this homework? Do you know that? This guy said he was a newbie! We all start somewhere! And I didn’t tell him how to read the file, which I suspect he was actually looking for ;-))
Also, a vector for this problem will work, but is a totally top-heavy solution for what he wants that any good teacher will jump on immediately, thus teaching him a further lesson! But if he is a genuine “newbie” the vector solution will serve him well, and teach him his first step into STL – so a win-win, don’t you think!
Oh GCDEF…. Seriously! Is this homework? Do you know that? This guy said he was a newbie! We all start somewhere! And I didn’t tell him how to read the file, which I suspect he was actually looking for ;-))
Also, a vector for this problem will work, but is a totally top-heavy solution for what he wants that any good teacher will jump on immediately, thus teaching him a further lesson! But if he is a genuine “newbie” the vector solution will serve him well, and teach him his first step into STL – so a win-win, don’t you think!
Why are you policing these threads?
With 45 posts in 6 years, you're probably not familiar with how this forum works. We don't do homework for people, and that's very obviously homework.
And no, I don't think doing somebody's work for them is win/win.
I would advise you to come up with a consistent and meaningful style of indentation and alignment though.
I'm not going to engage in a pissing match with you. I'm just pointing out how the forum works. If I hadn't, somebody else would have.
I’m sorry, but I seriously do not understand what in God’s name you have for a bee in your bonnet about! If I do anything untoward then admin here will tell me and not you! And, words like p***ing are not very nice!
I am sorry if I embarrassed you over the int char thing! But that is not any reason to stalk my threads and hit me on “indentation” – I am on a Galaxy SII phone for Pete’s sake! Try indenting code on this thing.
Bookmarks