drawing - Java Pattern Design -
i trying make pattern on java:
******* ****** ***** **** *** ** *
however, till have been able produce code:
public class pattern { public static void main(string [] args) { int height = 7; (int = 0; <= height; i++ ) { (int j = 0; j <= ; j++) { system.out.print("*"); } system.out.println(); } } }
this code can produce image:
* ** *** **** ***** ****** ******* ********
what part of code should change able produce first image?
thanks help, apologize if wrong question appreciate help.
int height = 7; (int = height; i>=1; i-- ) { //reverse,and change '0' '1' int space_cnt = height - i; //number of space need (int j = 1; j <= height ; j++) { if(space_cnt-->0){ system.out.print(" "); }else{ system.out.print("*"); } } system.out.println(); }
Comments
Post a Comment