js题。用for循环输出
1个回答
展开全部
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>菱形</title>
<script>
document.write( "<table>" );
for ( var i = 1; i <= 9; i++ ) {
if ( i <= 5 ){
document.write( "<tr>" );
for ( var j = 1; j <= 5 - i; j++ ) {
document.write( "<td> </td>" );
}
for ( var j = 1; j <= 2 * i - 1; j++ ) {
document.write( "<td>*</td>" );
}
document.write( "</tr>" );
}
}
document.write( "</table>" );
</script>
<style>
table {
border-collapse:collapse;
}
td {
padding:5px;
}
</style>
</head>
<body>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询