Created
October 22, 2019 07:16
-
-
Save samirmhsnv/ce6d7b8b351923fcf494016ec7ab6ec5 to your computer and use it in GitHub Desktop.
romb.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
romb(10); | |
} | |
private static void romb (int k){ | |
for (int i = 0; i < k; i++){ | |
print_star(k, i); | |
} | |
for (int i = k-2; i >= 0; i--){ | |
print_star(k, i); | |
} | |
} | |
private static void print_star(int k, int i) { | |
for (int j = 0; j<(k*2-(i*2+1))/2; j++) | |
System.out.print(" "); | |
for (int j = 0; j < i*2+1; j++) | |
System.out.print("*"); | |
for (int j = 0; j<(k*2-(i*2+1))/2; j++) | |
System.out.print(" "); | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment