3
2

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 3 years have 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
3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?