[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>
게시글 목록
| 번호 | 제목 |
|---|---|
| 101 | |
| 99 |
JavaScript
퍼미션관련 명령어
|
| 97 |
MySQL
MySQL 덤프방법(dump)
1
|
| 96 |
MySQL
여러데이터베이스 사용하는 방법
|
| 89 |
기타
PHP 기초 테크닉
6
|
| 81 |
기타
주요메타테그 모음
4
|
| 79 |
MySQL
백업&복구(전체/부분/테이블)
2
|
| 78 | |
| 77 | |
| 76 |
MySQL
리눅스 기본 명령어 모음[펌]
|
| 72 |
JavaScript
dhtml menu (pull down, top down 방식 메뉴)
4
|
| 69 | |
| 64 | |
| 61 | |
| 58 |
JavaScript
체크박스를 이미지로...
3
|
| 57 |
기타
리눅스의 디렉토리 구성
|
| 54 | |
| 53 | |
| 52 |
MySQL
MySQL root 패스워드 분실했을 경우
|
| 45 | |
| 35 |
JavaScript
PHP 홈페이지
10
|
| 28 | |
| 23 |
Linux
리눅스 배포판 선택하기
5
|
| 17 | |
| 13 | |
| 1 |
JavaScript
우편번호를 이용한 소재지 셀렉트 박스
12
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기