网页输出菱形

 

<%

String str1="";

for(int i = 0 ; i <5 ;i ++)
{
    for(int j = 0 ; j <5-i;j++)
        str1+="&nbsp;"+"&nbsp;";
    for(int x = 0 ; x <2*i-1;x++)
        str1+="*";
        str1+="<br>";
}

%>

<%=str1 %>

<%

String str2="";
for(int i= 3 ; i > 0 ; i-- )
{
    for(int j=0 ; j < 5 -  i ; j++)    
        
        str2+="&nbsp;"+"&nbsp;";
        
    for(int x=0 ; x < 2*i-1 ; x++)
        str2+="*";
        str2+="<br>";        
}

%>

<%=str2 %>

 

posted @ 2016-10-27 17:47  张好好  阅读(436)  评论(0编辑  收藏  举报