循环结构
for循环
一种特殊的方式
int[] numbers = {10,20,30,4,50};
for (int x:numbers) {
System.out.println(x);
}
打印三角形 5行
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5-i; j++) {
System.out.print(" ");//第一行打五个空格第二行四个。。。。
}
for (int k = 0; k < i+1; k++) {
System.out.print("*");
}
for (int k = 0; k < i; k++) {
System.out.print("*");
}
System.out.println();
}
标签:练习题,以及,int,System,++,循环,print,out
From: https://www.cnblogs.com/LiuWTaoRecord/p/17728794.html