<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=6-$y; $x<7; $x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=$y; $x<7; $x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x+$y < 7; $x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x<=$y; $x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
=>a
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; !($x+$y == 7); $x++){
if($x<=$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
=>b
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x<=$y; $x++){
if( $x+$y < 7)
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
=>c
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0;$x<=6;$x++){
if( $x+$y<7 && $x<=$y)
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
4가지 코드는 모두 다음과 같은형태
1. for문으로만 작성
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
#for문으로 만 작성
$cnt=1;
for($y=3; $y<=6; $y++){
for($x=6-$y; $x<=$y; $x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
2. 0.php에서 if문 추가
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
#0.php 에서 if 문 추가
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=6-$y; $x<7; $x++){
if($x<=$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
3. 3.php 에서 if문 추가
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
#3.php 에서 if문 추가
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x<=$y; $x++){
if( 6-$y <= $x)
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
4.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x < 7; $x++){
if($x<=$y && 6-$y <= $x){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
1. A
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=6-$y; $x<7; $x++){
if($x>=$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
2. B
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=$y; $x<7; $x++){
if($x>=6-$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
3. C
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=$y; $x<7; $x++){
if($x+$y<=6){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x+$y < 7; $x++){
if($x>=$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x<7; $x++){
if($x+$y<=6 && $x>=$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x<7; $x++){
if($x>=$y && $x>=6-$y || $x+$y<7 && $x<=$y){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0; $x < 7; $x++){
if( $x == $y || $x+$y == 6 || $x*$y == 3 || $x * $y == 15){
$a[$y][$x]=$cnt++;
}
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
'이전것 > 개발' 카테고리의 다른 글
https://play-entry.org/tt#!/basic/solve (0) | 2016.07.06 |
---|---|
php -> cross array (0) | 2016.07.06 |
php -> make table, array, triangle (0) | 2016.07.05 |
HTML5 (3) 로그인 폼 (0) | 2016.07.05 |
HTML5 (2) (0) | 2016.07.05 |