I need to create a console program in C that prints out a Pascal triangle in a size given by the user. I can only use one array for this.
Originally Posted by xpi0t0sLooking at the Wiki article on Pascal's triangle it could be a lot easier to calculate each line from the previous line as per the standard construction.
So get the input from the user and that will tell you (indirectly) the size of the array needed.
This size must be odd, of course.
Place a 1 in the middle and set all other elements to 0.
Then display that line and that will be the top line.
Then calculate the next row just by looking at the array entries and updating them as you go along. You don't need a second array for this as the numbers don't overlap.