public class do while {
public static void main(String[] args) {
int N = 5;
int i = 1;
int N = 5;
int i = 1;
do {
int j = 1;
do {
if ((j == i) || (j == N+1-i))
System.out.print(“#”);
else
System.out.print(” “);
j++;
}
while (j <= N);
System.out.println();
i++;
}
while (i <= N);
}
}
int j = 1;
do {
if ((j == i) || (j == N+1-i))
System.out.print(“#”);
else
System.out.print(” “);
j++;
}
while (j <= N);
System.out.println();
i++;
}
while (i <= N);
}
}
Tags : Java, do while, program java, do, while
Mksih buat programnya, bisa sharing program dengan blog saya juga. :)
BalasHapuskunjungi balik blog saya juga tentang while :
http://top-ilmu.blogspot.com/2012/11/contoh-program-java-while-dan-do-while.html
mksih. :)