0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【PHP】 paizaスキルチェック 一番小さい値 解答

Posted at

問題はこちら

解答

answer.php
<?php
    //入力された整数を格納する配列
    $numbers = [];
    
    //各行の整数を読み込む
    for ($i = 0; $i < 5; $i++) {
        $number = trim(fgets(STDIN));
        $numbers[] = intval($number);
    }
    //配列から最小値を求める
    $minNumber = min($numbers);
    
    //最小値を出力
    echo $minNumber;
?>

Point

今回ですが、まず5つの整数を格納する配列を作成して、for文で実際に整数を格納していき、min関数を使って最小値を求めるという手順で書いてみました。

参照

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?