まとめ @ wiki
乱数表を作成する-Mathクラス-
最終更新:
shells
-
view
乱数表を作成する-Mathクラス- 【HP】
目次
ソース
random.jsp
<%@ page contentType="text/html;charset=Shift_JIS" %>
<table border = "1">
<%
for ( int i = 0; i < 10; i++ ) {
out.print("<tr>");
for ( int j = 0; j < 10; j++ ) {
out.print( "<td>" + Math.round( Math.random() * 100 ) + "</td>" ); // randomメソッドは 0.0~1.0の乱数を表示
// その為100を掛け小数点以下を切り捨てる事で、0~100までの値を取得
}
out.print( "</tr>" );
}
%>
</table>実行結果
0~100までのランダムな数字が並んだ表