Skip to content

Instantly share code, notes, and snippets.

@mkdika
Created September 21, 2016 01:09
Show Gist options
  • Save mkdika/8f6d15144699a8eb4a3c20c7f965037f to your computer and use it in GitHub Desktop.
Save mkdika/8f6d15144699a8eb4a3c20c7f965037f to your computer and use it in GitHub Desktop.
public class KompasChallange {
public static void main(String[] args) {
int x = 30; // banyaknya baris yang diinginkan
int i = ((x * 2) - 1), n = 0;
while (i > 0) {
for (int j = 0; j < ((x + (x - 1))); j++) {
String c = ((j >= n && j < (x + (x - 1) - n)) ? "*" : " ");
System.out.print(c);
}
System.out.println("");
if (i <= x) {
n--;
} else {
n++;
}
i--;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment