테스트 사이트 - 개발 중인 베타 버전입니다

[PHP 기초] 구구단표 만들기

· 20년 전 · 18398
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><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
26560
24588
31642
31638
31633
31630
31625
19452
6719
6718
6717
6715
27797
30907
30904
6714
6713
27791
19450
6712
6711
6709
6708
27790
19447
6706
6703
6702
6701
6697
6692
27783
6691
6687
6685
6683
6682
19446
27770
19445
27768
6681
6675
6674
19444
6672
6671
27761
6670
30900
24585
6660
6655
6653
31624
6651
31623
31621
19443
6650
31620
31619
31612
31611
27746
31605
6648
20781
31603
31600
6645
6643
6642
6640
20777
31597
6637
19442
31594
31591
31589
31586
31584
20758
19440
31575
31567
20747
6636
31563
31552
27743
24579
6630
6628
6620
6617
27732
24577
6616