Skip to content

Instantly share code, notes, and snippets.

@SeptiyanAndika
Last active December 16, 2017 13:50
Show Gist options
  • Select an option

  • Save SeptiyanAndika/3495d9f97ec0e2e74357ec93cd721d2a to your computer and use it in GitHub Desktop.

Select an option

Save SeptiyanAndika/3495d9f97ec0e2e74357ec93cd721d2a to your computer and use it in GitHub Desktop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
/**
*
* @author andika
*/
public class test {
public static void main(String[] args) {
int x = 5;
int print = x;
boolean plus = true;
for (int i = 0; i < x ;i++) {
for (int j = x-1; j >=0; j--) {
if(i==j || j==0 || i==(x-1) ){
int intprint = (print==10)?0:print;
System.out.print(intprint);
if(plus){
print++;
}else{
print--;
}
if(print==0 || print==10){
plus=!plus;
}
}else{
System.out.print(" ");
}
}
System.out.println("");
}
}
}
@SeptiyanAndika
Copy link
Copy Markdown
Author

output contoh
run:
5
6 7
8 9
0 9
87654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment