{class ServiceDemo public
public static void main (String [] args) {
/ *
* print cycle for the use of double diamond
*
* for the three nested loop generally up
*
* /
// outer loop cycle represents the number of rows
for (int I = 0; I <=. 5; I ++) {
for (int. 5 = J; J> = I; J -) {
of System.out.print ( "");
}
for (int. 1 K = ; K <= I-2 *. 1; K ++) {
of System.out.print ( "*");
}
System.out.println ();
}
for (int I =. 4; I> = 0; I -) {
for (int. 5 = J; J> = I; J -) {
System.out.print(" ");
}
for(int k = 1; k <= 2*i-1 ; k++){
System.out.print("*");
}
System.out.println();
}
}
}
java achieve print diamond
Guess you like
Origin blog.csdn.net/sj_1993/article/details/103247250
Recommended
Ranking