首页 > 技术文章 > 网页输出菱形

zs6666 2016-10-27 17:47 原文

 

<%

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 %>

 

推荐阅读