I will post somehow. I was writing a program in ruby, but I noticed that I am still not familiar with arrays. For example this
qiita.rb
xc,yc,r_1,r_2 = gets.chomp.split(' ').map{|i| i.to_i}
n = gets.to_i
x = []
y = []
n.times do
a,b = gets.chomp.split(' ').map{|i| i.to_i}
x.push a
y.push b
end
c = 0
while n > 0 do
if r_1**2 <= ((x[c] - xc)**2 + (y[c] - yc)**2) && (x[c] - xc)**2 + ((y[c] - yc)**2) <= r_2**2
puts "yes"
else
puts "no"
end
n = n - 1
c = c + 1
end
I don't care about the contents of the process (while) this time.
By the time Definition of x and y arrays Define variables a and b Store a and b variables in an array in order
Is repeated. While thinking that I'm writing a code that looks like a fool I can't think of any better means.
Normally, a, b, etc. are not used
qiita.rb
x,y = gets.chomp.split(' ').map{|i| i.to_i}
I wish I could store it in this form from the beginning. I would like to find a way again.
Recommended Posts