<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title></title></head><body> <script type="text/javascript">// // 最后打出等腰三角形// var i;// var j;// var k;// function triangle(x,y)// {//// for(i=0;i<=x;i++)// {// for(k=0;k<=6-i;k++)// {// document.write (" ");// }// for(j=0;j<2*i-1;j++)// {// document.write("*");// }//// document.write("<br/>");// }// }//// document.write(triangle(3,4));// triangle(7,9); // 打出空心平行四边形var i;var j;var k;function triangle(x,y){ for(i=0;i<=y;i++) { for(k=0;k<=6+i;k++) { document.write (" "); } for(j=0;j<x;j++) {// document.write("*"); if(i>=1 && i<y){ if(j>=1 && j<x-1){ document.write(" "); }else{ document.write("*"); } }else{ document.write("*"); } } document.write("<br/>"); }}// document.write(triangle(3,4));triangle(33,18); </script></body></html>
时间: 2024-10-24 19:43:15