I need help with part of some codes I'm writing. It outputs the spaceneedle. I need to draw out the top and bottom of it. Here is the picture.
__/||\__
__/:::||:::\__
__/::::::||::::::\__
__/:::::::::||:::::::::\__
The bottom looks like this:
\_/\/\/\/\/\/\/\/\/\/\/\_/
\_/\/\/\/\/\/\/\/\/\_/
\_/\/\/\/\/\/\/\_/
\_/\/\/\/\/\_/
Hope these look right here...
---------- Post added at 05:51 PM ---------- Previous post was at 05:43 PM ----------
Hmm they didn't turn out looking right after all... But it's supposed to look like the SpaceNeedle from Seattle. Any help would be appreciated!
3 replies to this topic
#1
Posted 27 September 2011 - 05:51 PM
|
|
|
#2
Posted 27 September 2011 - 07:12 PM
So what are your guess... do you have something to start with?
#3
Posted 27 September 2011 - 08:08 PM
Here is what I have... they're not loops though!
public static void drawTop() // draw the top of the space needle
{
System.out.println (" __/||\\__ ");
System.out.println (" __/:::||:::\\__ ");
System.out.println (" __/::::::||::::::\\__ ");
System.out.println ("__/:::::::::||:::::::::\\__");
}
public static void drawSlashes() // draw slashes in the output
{
System.out.println ("\\_/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\_/");
System.out.println (" \\_/\\/\\/\\/\\/\\/\\/\\/\\/\\_/ ");
System.out.println (" \\_/\\/\\/\\/\\/\\/\\/\\_/ ");
System.out.println (" \\_/\\/\\/\\/\\/\\_/ ");
}
public static void drawTop() // draw the top of the space needle
{
System.out.println (" __/||\\__ ");
System.out.println (" __/:::||:::\\__ ");
System.out.println (" __/::::::||::::::\\__ ");
System.out.println ("__/:::::::::||:::::::::\\__");
}
public static void drawSlashes() // draw slashes in the output
{
System.out.println ("\\_/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\_/");
System.out.println (" \\_/\\/\\/\\/\\/\\/\\/\\/\\/\\_/ ");
System.out.println (" \\_/\\/\\/\\/\\/\\/\\/\\_/ ");
System.out.println (" \\_/\\/\\/\\/\\/\\_/ ");
}
#4
Posted 28 September 2011 - 01:47 AM
If the top and bottom have n layers. You need one loop to repeat the other loop n times, which prints the colons n*3 times for both sides.
During the printing, you need to place __/ and || and \__ where appropriate.
Something like this in pseudocode:
During the printing, you need to place __/ and || and \__ where appropriate.
Something like this in pseudocode:
layers = 3;
for(row = 0; row < layers; row++){
print("__/");
for(column = 0; column < row*3; column++)
print(":");
print("||");
for(column = 0; column < row*3; column++)
print(":");
print("\\__");
}
you need to add the right amount of whitespace too.
__/||\__
__/:::||:::\__
__/::::::||::::::\__
__/:::::::::||:::::::::\__
\_/\/\/\/\/\/\/\/\/\/\/\_/
\_/\/\/\/\/\/\/\/\/\_/
\_/\/\/\/\/\/\/\_/
\_/\/\/\/\/\_/
The bottom uses the same logic, but is easier to implement, because it has no middle separator.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









