Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
susun
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { //Scanner sc = new Scanner(System.in); //System.out.print("Masukkan nilai tingkat pertama : "); //int tingkat = sc.nextInt(); System.out.println("Input tingkat : 5"); printSusun(5); System.out.println("---------------------"); System.out.println("Input tingkat : 7"); printSusun(7); } public static void printSusun(int tingkat){ for(int i=tingkat; i>=(tingkat/2)+1; i--){ int space =0; for(int j=tingkat; j>i;j--){ System.out.print(" "); space++; } for(int a=i; a>(i/2)+1; a--){ System.out.print(a); } for(int b=(i/2)+1; b>=space+1; b--){ System.out.print(b); } System.out.println(); } for(int i=(tingkat/2); i>=1; i--){ int space = 0; for(int j=i; j>1;j--){ System.out.print(" "); space++; }for(int a = i; a<(tingkat/2)+1; a++){ System.out.print(a); }for(int b = (tingkat/2)+1; b<=tingkat-space; b++){ System.out.print(b); } System.out.println(); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Find if a String2 is substring of String1
Java - SimpleDateFormat(ting) for XML
hextoepeen
Problem_OnOff
l
vsecodertest2
Star
homework
java palindrome check
sortArraymerge
stackse - search stackoverflow differently
Please log in to post a comment.