jsp 输出杨辉三角

很简单,直接上代码把

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    This is my JSP page. <br>
      <% int [] a=new int[10];
    	int previous=1;
    	for(int i=1;i<=8;i++){
    		for(int j=1;j<=i;j++){
    			int current = a[j];
                a[j] = previous + current;
                previous = current;%>
                <%= a[j] %><% 
                
    		}%>
    		<br>
   <% }%>
  </body>
</html>
    原文作者:杨辉三角问题
    原文地址: https://blog.csdn.net/LZK1997/article/details/77936209
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞