Skip to content

Instantly share code, notes, and snippets.

@samirmhsnv
Created October 22, 2019 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samirmhsnv/ce6d7b8b351923fcf494016ec7ab6ec5 to your computer and use it in GitHub Desktop.
Save samirmhsnv/ce6d7b8b351923fcf494016ec7ab6ec5 to your computer and use it in GitHub Desktop.
romb.java
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