public class ForFor {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
*****
****
***
**
*
for(int x=5; x>0; x--)
{
for(int y=x; y>0; y--)
System.out.print("*");
System.out.println();
}
*/
/*
*
**
***
****
*****
for(int x=1; x<=5; x++)
{
for(int y=1; y<=x; y++)
System.out.print("*");
System.out.println();
}
*/
/*
54321
5432
543
54
5
*/
for(int x=0; x<5; x++)
{
for(int y=5; y>x; y--)
System.out.print(y);
System.out.println();
}
/*
1
22
333
4444
55555
*/
for(int x=1; x<=5; x++)
{
for(int y=1; y<=x; y++)
System.out.print(x);
System.out.println();
}
/*
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
....................
*/
for(int x=1; x<=9; x++)
{
for(int y=1; y<=x; y++)
System.out.print(y+"*"+x+"="+x*y+"\t");
System.out.println();
}
/*
\n:回车
\t:制表符
\b:退格
\r:按下回车键 1111111111111111111重要
windows系统中回车符是由两个符号组成 \r\n
在很多情况下 \n并不奏效
linux中回车符是 \n
*/
/*
* * * * *
* * * *
* * *
* *
*
分析:
第一行 0空格 打印5个"* "
第二行 1空格 4个
第三行 2空格 3个
第四行 3空格 2个
第五行 4空格 1个
*/
for(int x=1; x<=5; x++)
{
for(int z=0; z<x-1; z++)
System.out.print(" ");
for(int y=1; y<=6-x; y++)
System.out.print("* ");
System.out.println();
}
}
}
for的图形练习与转义字符注意点
最新推荐文章于 2022-07-26 13:37:28 发布