Last active
February 23, 2016 18:12
-
-
Save gartnera/a906f2777def98da1657 to your computer and use it in GitHub Desktop.
Assignment 4 Pseudocode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for 0 to height | |
for 0 to outer index | |
print star | |
print newline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for loop for length, for loop for width | |
for 0 to length | |
for 0 to width | |
print star | |
print newline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//two approaches | |
//first: | |
read into choice | |
while choice not zero | |
sum + choice | |
read into choice | |
//second: | |
while (read into choice) not zero | |
sum + choice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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