Results 1 to 2 of 2
Thread: Star triangle with boolean array
- 01-05-2012, 01:06 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 3
- Rep Power
- 0
Star triangle with boolean array
Hey guys.
My task is to print out a equal-sided triangle, like this:
____*
___***
__*****
(__ are empty spaces)
I have to use a boolean[][] array. Everytime when a star has to be drawn, true should be returned. If a space character, false should be returned.
Heres my code.
I hope someone can help me. Thanks!!Java Code:public class Application { public static void main(String[] args) { int eingabe = 3; int anzahl = eingabe; boolean[][] matrix = new boolean[eingabe][]; for ( int j = 0; j<matrix.length ; j++ ){ for(int i=0; i<anzahl; i++) matrix[ j ]= new boolean[ j + eingabe]; } for ( int i = 0 ; i < matrix.length ; i++ ) { for ( int j = 0 ; j < matrix[i].length ; j++ ) System.out.print( matrix[i][j] + " " ); System.out.println(); }
- 01-05-2012, 02:04 AM #2
Re: Star triangle with boolean array
Do you have a question?
Does you code compile and execute? What happens?
Copy and post here the output from your code if you are asking for help with your program.
What is the logic for your code? What does it do for each row?
How many spaces and how many *s does it output for each row?
What is the relationship between the row number and the number of spaces and the number of *s
One thing I don't see is the '*' character that is to be printed out.
Similar Threads
-
Star triangle with boolean array
By helostcontrol in forum New To JavaReplies: 1Last Post: 01-05-2012, 01:15 AM -
Boolean.True and Boolean.False, why do some people use these?
By Pojahn_M in forum New To JavaReplies: 3Last Post: 09-13-2011, 12:01 AM -
Boolean array Question
By elm101 in forum New To JavaReplies: 10Last Post: 06-01-2011, 07:02 AM -
Star triangle pattern
By crazy4fun in forum New To JavaReplies: 7Last Post: 03-06-2011, 01:03 PM -
star array
By nanna in forum New To JavaReplies: 4Last Post: 11-23-2008, 07:58 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks