Results 1 to 2 of 2
  1. #1
    helostcontrol is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Star triangle with boolean array

    Hey guys.
    My task is to print out a equal-sided triangle, like this:

    *
    ***
    *****

    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.
    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();
    	  }
    I hope someone can help me. Thanks!!
    Last edited by pbrockway2; 01-05-2012 at 02:09 AM. Reason: closing code tag added

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Star triangle with boolean array

    Duplicate of this with better formatting. Locking.

Similar Threads

  1. Replies: 3
    Last Post: 09-13-2011, 01:01 AM
  2. Boolean array Question
    By elm101 in forum New To Java
    Replies: 10
    Last Post: 06-01-2011, 08:02 AM
  3. Star triangle pattern
    By crazy4fun in forum New To Java
    Replies: 7
    Last Post: 03-06-2011, 02:03 PM
  4. Need Help with A star
    By 256mxr in forum New To Java
    Replies: 3
    Last Post: 10-11-2009, 03:50 PM
  5. star array
    By nanna in forum New To Java
    Replies: 4
    Last Post: 11-23-2008, 08:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •