如何打印?向後嵌套For循環在Java中?
!!!!!!!!!!!!!!!!!!!!!!
\\!!!!!!!!!!!!!!!!!!//
\\\\!!!!!!!!!!!!!!////
\\\\\\!!!!!!!!!!//////
\\\\\\\\!!!!!!////////
\\\\\\\\\\!!//////////
我:
public class SlashFigure {
public static void main(String[] args){
first();
}
public static void first() {
for ( int i= 1; i<=6; i++) {
for (int l = 0; l <= 2 * i -2; l++) {
System.out.print("\\");
}
for (int e = 22; e >= -2*i + 26; e-=1) {
System.out.print("!");
}
for (int r = 0; r <= 2 * i -2; r++) {
System.out.print("/");
}
System.out.println();
}
}
}
,它的印刷本:
\/
\\\!///
\\\\\!!!/////
\\\\\\\!!!!!///////
\\\\\\\\\!!!!!!!/////////
\\\\\\\\\\\!!!!!!!!!///////////
參見http://stackoverflow.com/questions/580269/reverse-iteration-through-arraylist-gives-indexoutofboundsexception/1063588#1063588 – 2014-09-28 03:55:23