Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

plotting comparison graph with C++ console i was thinking of using 2d arrays, but i am stuck on them. any help or suggestion is appreciated

OpenStudy (anonymous):

i don't know where to start, i had a nested loop to start of, but i didn't know where to go after that and the also the graph doesn't need to be connected with a line, it should just be a point or a stars or something

OpenStudy (anonymous):

@e.mccormick

OpenStudy (e.mccormick):

Well, you will need to draw it out. How you do that is going to depends on what characters you choose to use. If you want to ue an array, you could make the array represent the entire graphed area, then plot points as values in the array.

OpenStudy (anonymous):

i thought a array would make it easy, so if i do create a array that would represent the entire graphed area, how would i plot the points insides them?

OpenStudy (e.mccormick):

This does not work great here.... better in a text editor like notpad. The spacing is all messed up. ``` 1 2 3 4 1234567890123456789012345678901234567890 y * y y y y * y y xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx y y y * y y y y ``` My point was that if the graph has negatives, you will need to do shifts on what goes where in the array.

OpenStudy (e.mccormick):

array[0][0] is going to be the upper left corner. So if the real (0,0) is going to be at (20,8) you will need to map that out as part of translating things. While the x may or may not need translation, the y always will because you start at the top.

OpenStudy (anonymous):

okay i understand, so what if it was in a situation like where the printed numbers are not known, but generated randomly, will it work the same way?

OpenStudy (e.mccormick):

Well, you are goig to have some function that is going to make a Y for the given X, right? The thing that puts this into the array will do the shifts before marking the spot in the character array with a *. So (x,y) + (10,20) for example. So lets say the function is 2x-1 to get the y value and you randmly get x=-5. So -10-1=-11. So the value to plot is (-5,-11). Then you pass that to the plotting function that actually stores it in the character array. Well, it stores a * at the position [x+10][y+20] so that when the array prints it puts the * at the right place.

OpenStudy (anonymous):

that makes sense, i am working with large numbers of arrays as instructed by the professors, so if i have array of [1000][1000] and lets say that when the x is 500, and the y is 10, that would be (500,10) which will put that in a position array of [500][10] correct ?

OpenStudy (e.mccormick):

And how are you supposed to display that on console? Just an approximate?

OpenStudy (e.mccormick):

The typical console is 80x25. So, a tad limited when to comes to large numbers.

OpenStudy (anonymous):

he wants us to show nine point samples , but he wants us to run the program millions of times with in array and divide it in 9 times and take the average, that average is the one we're suppose to graph i guess

OpenStudy (anonymous):

but i'm only gonna make <20 array size for the graph, that would make it have a good full output of the graph

OpenStudy (e.mccormick):

OK.

OpenStudy (anonymous):

thanks for your help

OpenStudy (e.mccormick):

np. I hope you have a better idea what to code up now. So yah, deal with the numbers. Then use a function to make a character array based on your final data.

OpenStudy (anonymous):

i do now thanks to you

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!