Last active
December 16, 2017 13:50
-
-
Save SeptiyanAndika/3495d9f97ec0e2e74357ec93cd721d2a to your computer and use it in GitHub Desktop.
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
| /* | |
| * 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(""); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output contoh
run:
5
6 7
8 9
0 9
87654