사이트 내 전체검색
PHP
구구단 만들기
로빈아빠
https://cmd.kr/php/232 URL이 복사되었습니다.

본문

for문과 sprintf를 이용한 구구단표입니다.

- 소 스 -

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>구구단을 외자</title>
<style type=text/css>
td { font-size:12px; font-family:굴림체; color:#0000FF; line-height:1.3; }
</style>
</head>
<body bgcolor=#FFFFFF>
<table border=0 width=720 bgcolor=#F0F0F0>
<tr>
<?
for($dan=2; $dan<=9; $dan++) {
    echo "<td align=center bgcolor=#C0C0C0>$dan 단</td>\n";
}
?>
</tr>
<?
// 구구단
for($gop=1; $gop<=9; $gop++) {
    echo "<tr>";
    for($dan=2; $dan<=9; $dan++) {
          $format = sprintf("%d * %d =&nbsp;%2d", $dan, $gop, $dan * $gop);
          echo "<td align=center bgcolor=#F0F0F0>$format</td>\n";
    }
    echo "</tr>\n";
}
?>
</table>
</body>
</html>

출처 : http://qdata.co.kr/bo/bbs/board.php?bo_table=pht&wr_id=67

댓글목록

등록된 댓글이 없습니다.

PHP
871 (1/18P)

Search

Copyright © Cmd 명령어 18.119.248.159