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?

More than 5 years have passed since last update.

PHP標準入力(足し算)

Posted at

PHP標準入力(足し算)

私はどうしても標準入力が苦手で…:sweat_smile:
まず簡単な足し算からと思い、検索したら
理解できました!:relaxed:
配列自体は基本的なことは理解してるので、そんなに難しくなかったですね!

入力値が横の場合

5 7 8
$i=trim(fgets(STDIN));
$o=explode(" ",$i);
$p=$o[0]+$o[1]+$o[2];
echo $p;

入力値が縦の場合

5
7
8
$i=trim(fgets(STDIN));
$o=trim(fgets(STDIN));
$p=trim(fgets(STDIN));
echo $i+$o+$p;

足したらどちらも合計20になります!
プログラミング始めて2ヶ月ぐらいなので簡単なことでも思ったことがあればアウトプットしていきます。

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?