|
|
(5 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | {{1010PrAD|ProblemName=Evergreens are a great pointy companion around the holidays. Or in the middle of July really. Today your going to draw one with text on the console using System.out. If you despise the idea of Christmas trees, imagine it's an awesome rocket ship!
| |
| | | |
− | |Problem= The problem is Edwin
| |
− |
| |
− |
| |
− | |SideSectionTitle=Getting Started
| |
− |
| |
− | |SideSection=
| |
− | [[Image:Wiki_loops01.jpg|center]]<BR>
| |
− |
| |
− | |Solution=The solution...
| |
− |
| |
− | |SolutionCode=class RocketTree
| |
− | {
| |
− | private static final int TREE_HEIGHT = 10;
| |
− |
| |
− | public static void main(String args[])
| |
− | {
| |
− | for (int a = 0; a < TREE_HEIGHT; a++)
| |
− | {
| |
− | // Make some inital space
| |
− | printChar(TREE_HEIGHT - a, ' ');
| |
− |
| |
− | // Draw zee tree
| |
− | printChar(a * 2, '*');
| |
− |
| |
− | System.out.println();
| |
− | }
| |
− |
| |
− | printChar(TREE_HEIGHT - 2 + 1, ' ');
| |
− | printChar(2, '|');
| |
− | System.out.println();
| |
− | }
| |
− |
| |
− | static void printChar(int howMuch, char out)
| |
− | {
| |
− | for (;howMuch > 0; howMuch--)
| |
− | {
| |
− | System.out.print(out);
| |
− | }
| |
− | }
| |
− | }
| |
− | }}
| |