[PHP 기초] 구구단표 만들기
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 = %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>
- 소 스 -
<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 = %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>
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 386 | Flash | 19년 전 | 3499 | ||
| 385 | Flash | 19년 전 | 4587 | ||
| 384 | Flash | 19년 전 | 5257 | ||
| 383 | 기타 | 19년 전 | 6170 | ||
| 382 | 기타 |
|
19년 전 | 3042 | |
| 381 | JavaScript | 19년 전 | 3949 | ||
| 380 | 기타 | 19년 전 | 3767 | ||
| 379 | MySQL | 19년 전 | 6094 | ||
| 378 | 기타 | 19년 전 | 4459 | ||
| 377 | Flash |
|
19년 전 | 4591 | |
| 376 | Flash |
|
19년 전 | 5079 | |
| 375 | 기타 |
|
19년 전 | 3030 | |
| 374 | JavaScript | 19년 전 | 4169 | ||
| 373 | 기타 | 19년 전 | 3585 | ||
| 372 | Flash | 19년 전 | 6192 | ||
| 371 | 기타 | 19년 전 | 4940 | ||
| 370 | JavaScript |
NeoGenesis
|
19년 전 | 5397 | |
| 369 | 기타 | 19년 전 | 4102 | ||
| 368 | 기타 | 19년 전 | 5049 | ||
| 367 | 기타 | 19년 전 | 4039 | ||
| 366 | JavaScript | 19년 전 | 4246 | ||
| 365 | 기타 | 19년 전 | 4057 | ||
| 364 | JavaScript | 19년 전 | 4590 | ||
| 363 | 기타 | 19년 전 | 3149 | ||
| 362 | JavaScript | 19년 전 | 5019 | ||
| 361 | JavaScript | 19년 전 | 4034 | ||
| 360 | 기타 | 19년 전 | 3592 | ||
| 359 | 기타 | 19년 전 | 4471 | ||
| 358 | 기타 | 19년 전 | 3622 | ||
| 357 | PHP | 19년 전 | 8184 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기