开发者

Vertical Bar Graphs in C?

I want to make a vertical bar graph in c, such that the user enters some marks, we take out percentage and represent it in form of a graph. I've done this in horizontal graph. Can someone suggest for a vertical one?

It should look like this:

###     
###     
###  ###
###  ###
###  ###  ###  ###
###  ###  ###  ###
###  ###  ###  ###
###  ###  ###  ###
math sci  cs   che开发者_开发问答m


Let's say your implementation assumes the horizontal graph is represented by a matrix. If so, what you want can be achieved by doing a transposition of said matrix.

I.E. you can achieve what you want by using a reversed for loop.


Find the tallest datapoint, and use that as a 0 in a for loop. Print out the row. Keep printing rows until you hit the next highest datapoint (so the graph would be printed for index (tallestheight-heightofcurrentdatapoint) on down.

#       i = 0
#
#  # <--------i = tallest - current = 5-3 (starts at i = 2)
#  #  # <-----i = tallest - current = 5-2 (starts at i = 3)
#  #  #
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜