LoginSignup
1
1

More than 1 year has passed since last update.

文字列の左から何番目の文字を出力する

Posted at

文字列の左から何番目の文字を出力するpaizaの問題集の課題を解きました

# 文字の左から何番目の文字を取り出す
# 標準入力
input_line = gets
# 文字列を1文字ずつ配列に格納する
array1 = input_line.split('')
#
num = gets.to_i
# 表示する
puts array1[num-1]
1
1
4

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
1