六个 for 循环的Java小程序源码展播
1、
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是运行结果:
**********
*********
********
*******
******
*****
****
***
**
*
*/
public class xinghaoone {
public static void main(string[] args) {
for(int i=10;i>0;i--){
for (int j=0; j < 10-i; j++) {
system.out.print(" ");
}
for(int o=i;o>0;o--){
system.out.print("*");
}
system.out.print(" ");
}
}
2、
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是打印结果:
*
**
***
****
*****
******
*******
********
*********
**********
*/
public class xinghaotwo {
public static void main(string[] args) {
for(int i=10;i>0;i--){
for(int n=i;n<11;n++){
system.out.print("*");
}
system.out.print(" ");
}
}
}
3、
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是运行结果:
**********
*********
********
*******
******
*****
****
***
**
*
*/
public class xinghaothree {
public static void main(string[] args) {
for(int i=10;i>0;i--)
{
for(int j=0;j system.out.print("*");
system.out.print(" ");
}
}
}
4、
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是打印结果:
*
**
***
****
*****
******
*******
********
*********
**********
*/
public class xinghaofour {
public static void main(string[] args) {
for(int i=10;i>0;i--)
{
for(int j=i;j>1;j--){
system.out.print(" ");}
for(int n=i;n<11;n++){
system.out.print("*");
}
system.out.print(" ");
}
}
}
5、
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是运行结果:
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
*/
public class xinghaojuxing {
public static void main(string[] args) {
for(int i=10;i>0;i--){
for(int n=0;n system.out.print("*");
}
for(int j=i;j<11;j++){
system.out.print("*");
}
system.out.print(" ");
}
}
}
6、
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates(来源 www.iocblog.net)
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是打印结果:
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
*/
public class shishi {
public static void main(string[] args) {
for(int i=10;i>0;i--){
for(int f=0;f<10;f++){
system.out.print("*");}
system.out.print(" ");
}
}
}
再来个带 注释 的 :
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author diyer6
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
/*
此图是打印结果:
0**********
00*********
000********
0000*******
00000******
000000*****
0000000****
00000000***
000000000**
0000000000*
*/
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。