본문으로 바로가기

[JSP] 구구단 만들기

category Back-End/JSP 2018. 4. 16. 15:55


JSP를 사용하여 구구단을 만들어 보았습니다~~


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>구구단</title>
</head>
<body>
<center>
<table border =1 >
    <!-- 첫 줄 -->
    <tr>
    <td bgcolor="#F0AEE0"> </td>
    <%for(int i=2; i<=9; i++){    %>
     <td bgcolor="#F0AEE0"><%= i+"단" %></td>
    <% } %>
    </tr>
    
    <!-- 바깥 for -->
    <% for(int i=1; i<=9; i++){    %>
    <tr>
    <td width="50" align="center" bgcolor="#F0AEE0"><%=i%></td>
    
    <!-- 안쪽 for -->
    <% for(int j=2; j<=9; j++){%>
    <td><%=+ "*" + i + "=" + j * i  %></td>
    
    <%-- 안쪽 포문 닫음 --%><% } %>
    <!--바깥 포문  -->
    <!-- tr끝 --></tr>
    <!--바깥포문 닫음  --> <%%>
    
</table>
 </center>
</body>
</html>
cs






아래는 출력 결과입니다.