清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
print "Enter an amount: " amount = gets.to_f print "Convert it from what(inches, feet, miles, millimeters, centimeters, meters, or kilometers): " from = gets.chomp print "To what(same options): " to = gets.chomp # Set the values in relation to millimeters values ={ 'millimeters' => 1, 'centimeters' => 10, 'inches' => 25.7, 'feet' => 308.4, 'meters' => 1000, 'kilometers' => 1000000, 'miles' => 1628352 } total = (values[from] / values[to].to_f) * amount puts "That would be #{total} #{to}"