对于打印长方形,外循环控制的行数,内循环每一行的控制列数
/*
功能:九九乘法表
1*1=1
1*2=2 2*2=4
*/
class ForForTest
{
public static void main(String[] args)
{
/*
*
**
***
****
*****
尖朝上,可以改变条件,让条件随外循环变化
尖朝下,可以改变初始值,。。。。
*/
for (int x=0;x<=5 ;x++ )
{
for (int y=0;y<=x ;y++ )
{
System.out.print("*");
}
System.out.println();
}
System.out.print("-------------");
/*
1
12
123
1234
12345
*/
for (int x=1;x<=5;x++ )
{
for (int y=1;y<=x ;y++ )
{
System.out.print(y);
}
System.out.println();
}
System.out.print("---------");
/*
1*1=1
1*2=2 2*2=4
*/
for (int x=1; x<=5;x++ )
{
for (int y=1;y<=x ;y++ )
{
System.out.print(y+"*"+x+"="+y*x+"\t");
}
System.out.println();
}
}
}
/*
----*
---* *
--* * *
-* * * *
* * * * *
*/
class ForForTest2
{
public static void main(String[] args)
{
for (int x=0;x<=5 ;x++ )
{
for (int y=x;y<5 ;y++)
{
System.out.print("- ");
}
for (int z=0;z<=x ;z++ )
{
System.out.print("* ");
}
System.out.println();
}
System.out.println("Hello World!");
}
}