看我的终极for循环七十二变…..1.打印一个菱形{:8_548:} * *** ***** ******* ***** *** * public class LingXing { publicstatic void main(String[] args) { for(inti = 1; i <= 4; i++){ for(intj = 1; j <= 4-i; j++){ System.out.print(""); } for(intk = 1; k <= 2 * i - 1; k++){ System.out.print("*"); } System.out.println(); } for(inti = 3; i >= 1; i--){ for(intj = 1; j <= 4-i; j++){ System.out.print(""); } for(intk = 1; k <= 2 * i - 1; k++){ System.out.print("*"); } System.out.println(); } } }
|