标签:
1 <%@page import="java.text.SimpleDateFormat"%> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8"%> 4 <%@ page import="java.util.*" %> 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 6 <html> 7 <head> 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 9 <title>Insert title here</title> 10 </head> 11 <body> 12 <!-- 连接生成九九乘法表 --> 13 <% 14 //String str=""; 15 for(int i=1;i<10;i++) 16 { 17 for(int j=1;j<=i;j++) 18 { 19 //str+=j+"*"+i+"="+j*i; 20 //str+=" "; 21 //System.out.print(j+"*"+i+"="+j*i+"\t"); 22 %><%=j+"*"+i+"="+j*i+"\t" %> 23 <% }%> 24 <%="<br>" %> 25 26 <% }%> 27 <br> 28 <% 29 String st=""; 30 for(int q=1;q<10;q++) 31 { 32 for(int w=1;w<=q;w++) 33 { 34 st+=w+"*"+q+"="+w*q; 35 st+=" "; 36 } 37 st+="<br>"; 38 } 39 %> 40 <table width="440" height="85" border="1" cellpadding="0" cellspacing="0" style="font:9pt;" bordercolor="#FFFFF" > 41 <tr><td height="30" align="center">九九乘法表</td></tr> 42 <tr><td style="padding: 3pt;"><%=st %></td></tr> 43 </table> 44 45 <br> 46 <!-- 输出完整的时间 --> 47 <% 48 Date date=new Date(); 49 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 50 String today=sdf.format(date); 51 %> 52 当前时间:<%=today %> 53 <br> 54 <!-- 计算5! --> 55 <% 56 int s=1; 57 for(int k=1;k<=5;k++) 58 { 59 s=s*k; 60 } 61 %> 62 5的阶乘为:<%=s %> 63 <br> 64 <!-- 输出三角形 --> 65 <% for(int a=1;a<=10;a++) 66 { 67 for(int d=1;d<=10-a;d++) 68 {%> 69 <%=" "%> 70 <%}%> 71 <% 72 for(int f=1;f<=2*a-1;f++){%> 73 <%="*"%> 74 <% }%> 75 <%="<br>" %> 76 <% }%> 77 <br> 78 <% 79 String z=" "; 80 for(int x=1;x<=10;x++) 81 { 82 for(int c=1;c<=10-x;c++) 83 { 84 z+=" "; 85 } 86 for(int v=1;v<=2*x-1;v++) 87 { 88 z+="☆"; 89 } 90 z+="<br>"; 91 } 92 93 %> 94 <%=z %> 95 </body> 96 </html>
输出九九乘法表:
输出阶乘和当前时间:
输出三角形:
标签:
原文地址:http://www.cnblogs.com/yg6405816/p/5613321.html