这个题目一度让我恼怒,想不出来。最后还是Google了。
View Code JAVA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /*打印菱形*/ import java.util.*; public class HomeWork4_2 { public static void main(String[] args) { System.out.print("Please input the number of lofty's side:"); Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int m=0,n=0; for(int i=0;i<2*l;i++) { if(i |