//for的嵌套,拼三角形,在DOS中输出的规则是从上到下,不会出现其他,所以一行行分析找规律句OK
//输出四排五列*
class Practise2 {
public static void main(String[] args) {
/*for (int x = 1;x < 5 ;x++){
//System.out.println("*****");
for (int y = 1;y <6 ;y++ ){
System.out.print("*");
}
System.out.println();
}*/
//倒三角形
/*for (int x = 1;x <= 5 ;x++){
//System.out.println("*****");
for (int y = 1;y <=x ;y++ ){
System.out.print("*");
}
System.out.println();
}*/
//倒三角形
for (int x = 1;x <= 5 ;x++){
//System.out.println("*****");
for (int y = x;y <= 5 ;y++ ){
System.out.print("*");
}
System.out.println();
}
}
} |
|