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

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

· 20년 전 · 18402
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>

댓글 작성

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

로그인하기

게시글 목록

번호 제목
19528
6810
6807
6801
6798
6791
24615
24612
6788
30933
6784
6783
27834
19527
19526
19524
19521
6777
6770
19519
27823
6766
24604
6760
6757
30925
19518
30924
30923
6746
19516
30922
19515
30921
6732
27803
19508
19507
24599
19504
19501
19498
19497
19496
19495
19493
19492
19491
19490
19489
6721
6720
19488
19487
19486
19485
30919
19484
30913
30910
19483
19482
19478
30908
19477
31683
19475
19473
19471
19470
19469
19468
19467
19466
19464
19462
19461
19460
19459
31680
19458
19457
31676
31674
31671
31670
31669
31664
31663
31662
31658
31657
19456
19455
31655
31653
31649
31646
27800
19454