Skip to content

Instantly share code, notes, and snippets.

@gartnera
Last active February 23, 2016 18:12
Show Gist options
  • Save gartnera/a906f2777def98da1657 to your computer and use it in GitHub Desktop.
Save gartnera/a906f2777def98da1657 to your computer and use it in GitHub Desktop.
Assignment 4 Pseudocode
//three loops, one for upper, one for middle, one for lower
h = height / 2
if h is even
height - 1
//upper half
for height to 0
for 0 to outer index
print space
for 0 to (height - outer index)
print star
print newline
//middle row
for 0 to height
print star
//bottom row
for 0 to height
for 0 to outer index
print space
for 0 to (height - outer index)
print star
print newline
for 0 to height
for 0 to outer index
print star
print newline
for 0 to height
for 0 to outer index
if at edge
print star
else
print space
print newline
//How to tell if at edge:
*inner index equals 0 //left side
*inner index plus 1 equals outer index //right side
*outer index equals height //bottom
//for loop for length, for loop for width
for 0 to length
for 0 to width
print star
print newline
//two approaches
//first:
read into choice
while choice not zero
sum + choice
read into choice
//second:
while (read into choice) not zero
sum + choice
//outer for loop for each line, first inner for spaces, second inner for stars
for height to 0 //contains outer index
for 0 to outer index
print space
for 0 to (height - outer index)
print star
print newline
//increment or decrement x or y
If x < y
for x to y
print x
Else x > y
for y to x
print y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment