JSP第一周作业

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
 求1-100的偶数和?
    <hr>
    <br>
</body>

    <%
        int sum = 0;
    for(int i=0;i<100;i++){
        if(i%2==0){
            sum+=i;
        }
        
    }
    %>
    
1-100中间的偶数和是:
<%=sum%>
</html>

 

 

 

posted @ 2021-03-03 21:56  Pro郭永琪er  阅读(32)  评论(0编辑  收藏  举报