Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
# Hello World Program in Ruby
puts "Hello World!";
#Variables and expressions.
a = 10
b = 3 * a + 2
printf("%d %d\n", a, b);
# Type is dynamic.
b = "A string"
c = 'Another String'
print b + " and " + c + "\n"
# Hello World Program in Ruby
gamers_t1 = %w[a b c d e f g].shuffle
gamers_t2 = %w[h i j k l m n].shuffle
t1,t2=[],[]
gamers_t1.each.with_index(1) do |e, i|
(i % 2 == 0 ? t1 : t2) << e
end
gamers_t2.each.with_index(1) do |e, i|
(i % 2 != 0 ? t1 : t2) << e
end
puts 'Team1'
print t1
puts ''
puts ''
puts 'Team2'
print t2
@tab = Array.new(3) {Array.new 3, rand(0..1)}
for i in([email protected])
for j in ([email protected])
print "#{@tab[i][j]}\s"
end
print "\n"
end
print "\n"
@tab.each_index do |x|
subtab = @tab[x]
vec = @tab[x]
a = vec[x] + 1
print "#{vec[x]}\s" << a
subtab.each_index do |y|
# print "#{@tab[x][y]}\s"
end
print "\n"
end