package cn.imust.day01;
public class TestForCircle {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//the general rectangle
/*
******
******
******
******
******
*/
for (int x=0;x<5 ;x++ )//control the external circle
{
for (int y=0;y<5 ;y++ )//control the internal circle
{
System.out.print("*");
}
System.out.println();//just acting as line feed
}
//the triangle like this
/*
*
**
***
****
*****
*/
for (int x=0;x<5 ;x++ )
{
for (int y=0;y<=x ;y++ )
{
System.out.print("*");
}
System.out.println();
}
//the triangle like this
/*
*****
****
***
**
*
*/
for (int x=0;x<5 ;x++ )
{
for (int y=x;y<5 ;y++ )
{
System.out.print("*");
}
System.out.println();
}
/*
1
12
123
1234
12345
*/
for (int x=1;x<6 ;x++ )
{
for (int y=1;y<=x ;y++ )
{
System.out.print(y);
}
System.out.println();
}
}
}
一些for循环嵌套
最新推荐文章于 2021-05-18 05:15:44 发布