jsp 输出杨辉三角

来源:互联网 发布:阿里云服务器配置推荐 编辑:程序博客网 时间:2024/05/20 09:05

很简单,直接上代码把

<%@ 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>


原创粉丝点击