2013-09-13
展开全部
//第一种用String数组
public static void main(String[] args){
String[] wujiaoxing={" *"," * *","* * * *"," * *"," * *"," * * * *","* *"};
for(int i=0;i<wujiaoxing.length;i++){
System.out.println(wujiaoxing[i]);
}
} /*第二种用char数组
public class Test{
public static void main(String[] args){
char[][] pentagram={
{' ',' ',' ',' ','*','\r'},
{' ',' ',' ','*',' ','*','\r'},
{'*',' ','*',' ',' ',' ','*',' ','*','\r'},
{' ','*',' ',' ',' ',' ',' ','*','\r'},
{' ',' ','*',' ',' ',' ','*','\r'},
{' ','*',' ','*',' ','*',' ','*','\r'},
{'*',' ',' ',' ',' ',' ',' ',' ','*','\r'}
};
for(int i=0;i<7;i++){
for(int j=0;j<pentagram[i].length;j++){
System.out.print(pentagram[i][j]);
}
}
}
}*/ 或者你看看这个也行 http://blog.csdn.net/bao110908/archive/2007/11/27/1904452.aspx
public static void main(String[] args){
String[] wujiaoxing={" *"," * *","* * * *"," * *"," * *"," * * * *","* *"};
for(int i=0;i<wujiaoxing.length;i++){
System.out.println(wujiaoxing[i]);
}
} /*第二种用char数组
public class Test{
public static void main(String[] args){
char[][] pentagram={
{' ',' ',' ',' ','*','\r'},
{' ',' ',' ','*',' ','*','\r'},
{'*',' ','*',' ',' ',' ','*',' ','*','\r'},
{' ','*',' ',' ',' ',' ',' ','*','\r'},
{' ',' ','*',' ',' ',' ','*','\r'},
{' ','*',' ','*',' ','*',' ','*','\r'},
{'*',' ',' ',' ',' ',' ',' ',' ','*','\r'}
};
for(int i=0;i<7;i++){
for(int j=0;j<pentagram[i].length;j++){
System.out.print(pentagram[i][j]);
}
}
}
}*/ 或者你看看这个也行 http://blog.csdn.net/bao110908/archive/2007/11/27/1904452.aspx
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询