Quantcast
Channel: 配列タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 757

RubyでArrayを使う方法

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

Viewing all articles
Browse latest Browse all 757

Trending Articles