Created
August 31, 2013 22:24
-
-
Save epson121/6401040 to your computer and use it in GitHub Desktop.
Calculation for civil engineering task of vehicle performance. (in Croatian)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res = [] | |
8.times do | |
res << [rand(7..10), rand(3..4), rand(3..6), rand(2..4)] | |
end | |
14.times do | |
res << [rand(11..20), rand(5..7), rand(3..4), rand(3..4)] | |
end | |
2.times do | |
res << [rand(24..25), 2, rand(4..5), rand(2..3)] | |
end | |
1.times do | |
res << [rand(32..34), 4, 3, 3] | |
end | |
p " utovar okret istovar povratak" | |
res.shuffle.each do |v| | |
printf "%5s %5s %5s %5s\n", v[0], v[1], v[2], v[3] | |
end | |
p "----------------------------------------" | |
one = 0 | |
two = 0 | |
three = 0 | |
four = 0 | |
s = [0, 0, 0, 0] | |
res.each do |v| | |
one += v[0] | |
two += v[1] | |
three += v[2] | |
four += v[3] | |
end | |
printf "S: %3s %5s %5s %5s\n", one, two, three, four | |
puts "\n" | |
p "Utovar prosjek: " + one.to_s + "/25.0=#{one/25.0}" | |
p "Okret prosjek: " + two.to_s + "/25.0=#{two/25.0}" | |
p "Istovar prosjek: " + three.to_s + "/25.0=#{three/25.0}" | |
p "Okret nazad prosjek: " +four.to_s + "/25.0=#{four/25.0}" | |
puts "\n" | |
sums = [] | |
res.each do |elem| | |
sums << elem.inject(:+) | |
end | |
sum_koc = sums.inject(:+) | |
p "Zbroj svih vrijednosti: #{sum_koc}" | |
p "Zbroj svih podijeljen s 25.00: #{sum_koc/25.0}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment