javaweb--表格循环

时间:2025-04-09 08:14:11
  • <table>
  • <tr>
  • <%
  • Map<Integer,Integer> map=new HashMap<Integer,Integer>();
  • (1,100000);
  • (2,250000);
  • (3,80000);
  • (4,160000);
  • (5,79000);
  • (6,820000);
  • (7,431000);
  • (8,605550);
  • (9,120000);
  • (10,150000);
  • (11,230000);
  • (12,50000);
  • int minval=(1); //获取最小月份的值
  • int minstr=0; //获取最小的值月份
  • int maxval=(1); //获取最大月份的值
  • int maxstr=0; //获取最大的值的月份
  • for (int st:()) {
  • if((st)>maxval){ //判断最大的值
  • maxval=(st); //把值赋值给maxval
  • maxstr=st; //最大值对应的月份maxstr
  • }
  • if((st)<=minval){ //判断最小值
  • minval=(st); //把值赋值给mainval
  • minstr=st; //把最小值对应的月份赋值给minstr
  • }
  • %>
  • <td>
  • <%
  • (st+"月份"); //输出月份
  • %>
  • </td>
  • <%
  • }
  • %>
  • </tr>
  • <tr>
  • <%
  • for (int str:()) { //获取所有的值
  • %>
  • <td>
  • <%
  • ((str)); //输出值所有的值
  • %>
  • </td>
  • <%
  • }
  • %>
  • </tr>
  • </table>
  • <p>
  • 盈利最多的月份为<% (maxstr+"月份");%>,盈利金额为<% (maxval); %><br/>
  • 盈利最少的月份为<% (minstr+"月份");%>,盈利金额为<% (minval);%>
  • </p>