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 chem
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.
IE 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)
# # #
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.