1
0

【Ruby】問題集解答 Part2(paizaラーニング)

Posted at

3つのデータの入力 (paizaランク D 相当)

自分の解答

(思いつかなかった)

ChatGPTの解答

以下は、標準入力から3つの文字列を受け取り、それらを順に3行で出力するRubyのコードです。

ruby
# 3つの文字列を標準入力から受け取る
input = gets.chomp.split

# それぞれの文字列を順に3行で出力する
puts input[0]
puts input[1]
puts input[2]

このコードは、標準入力から1行を受け取り、それを半角スペースで分割して配列に格納します。そして、その配列の要素を順に3行で出力します。

1
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
1
0