Last active
March 27, 2020 13:04
-
-
Save chang180/ac6be0b44cdf55f6aa30fd93e7233a7f to your computer and use it in GitHub Desktop.
印星星-菱形
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
印空心菱形 | |
<hr> | |
<script type="text/javascript"> | |
let n = 10; | |
for (let i = 1; i < 2 * n; i++) { | |
k = 0; | |
for (let j = 1; j < 2 * n; j++) { | |
if (j + i == n + 1 || j + n == i + 1) { | |
k = j; | |
document.write("*"); | |
} else if (j - n == n - k) { | |
document.write("*"); | |
} else { | |
document.write(" "); | |
} | |
} | |
document.write("<br>"); | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$n=10; | |
for($i=1;$i<2*$n;$i++){ | |
$k=0; | |
for($j=1;$j<2*$n;$j++){ | |
if($j+$i==$n+1||$j+$n==$i+1){ | |
$k=$j; | |
echo "*"; | |
}else if($j-$n==$n-$k){ | |
echo "*"; | |
}else{ | |
echo " "; | |
} | |
} | |
echo "<br>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment