Files
2026-10-09 12:33:29 +09:00

30 lines
1.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$limit_number = 100;
// ランダムで数字を生成するプログラムです。
// 下記の命令を実行すると変数randomに、0以上、変数limit_number未満の数字がランダムで代入されます
$random = mt_rand(0, $limit_number);
// ---------------------ここから本題-----------------------
/*
* 以下の仕様に沿ってプログラムを完成させてください
*
* ●変数randomの値から、出力する値を変更します。
* ● 1%の確率 -> 「☆☆☆☆☆」
* ●30%の確率 -> 「☆☆☆☆」
* ●上記以外の場合 -> 「☆☆☆」
*
* ※ プログラムは何行書いても良いです
*/
// ランダムの値が0~99の間になる
if ($random == 0) {
// 100個の数値のうち1個だけ(つまり、1/100)
echo "☆☆☆☆☆";
} else if ($random <= 30) {
// 1~30の30個の数字が当てはまる(つまり、30/100)
echo "☆☆☆☆";
} else {
// 上の条件にかからなければ・・・
echo "☆☆☆";
}