java的循环跟C是一样滴!就是C语言的变种,不然为何C语言作为编程入门的基础呢.
#include
main()
{
int x,y;
for(y=0;y<=3;y++)
for(x=0;x<=5;x++)
{
if(x==5)
printf("*\n");
else if(x==0||y==0||y==3)
printf("*");
else printf(" ");
}
}
public static void main(String[] args) {
int x, y;
for (y = 0; y <= 3; y++){
for (x = 0; x <= 5; x++) {
if (x == 5)
System.out.print("*\n");
else if (x == 0 || y == 0 || y == 3)
System.out.print("*");
else
System.out.print(" ");
}
}
}