LoginSignup
2
1

More than 1 year has passed since last update.

RubyでArrayを使う方法です。

#数字を入力します
m = gets.to_i
#Array配列を定義します
c = Array.new(m)
m.times { |i| c[i] = gets.chomp }
#数字を入力します
n = gets.to_i
#文字列を入力します
s = Array.new(n)
n.times { |i| s[i] = gets.chomp }

c.each do |d|
  s.each do |t|
  #文字列が含まれているかチェックします
    if t.include? d
      puts 'YES'
    else
      puts 'NO'
    end
  end
end
2
1
2

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