`

Ruby Start

    博客分类:
  • Ruby
 
阅读更多
=begin
D:\>ruby a.rb
1*1=1
1*2=2  2*2=4
1*3=3  2*3=6  3*3=9
1*4=4  2*4=8  3*4=12 4*4=16
1*5=5  2*5=10 3*5=15 4*5=20 5*5=25
1*6=6  2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
1*7=7  2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
1*8=8  2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
1*9=9  2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
-------------------------------------------------------------------
input a number (1 - 10):
3
         *
      *      *
   *            *
*                  *
   *            *
      *      *
         *
=end

for i in 1..9
	for j in 1..i
		print j, "*", i, "=", i * j, (i * j < 10 ? "  " : " ")
	end
	puts
end

puts "-------------------------------------------------------------------"

puts "input a number (1 - 10):"
width = gets.to_i
i, j = width, 0
while i.abs <= width
	print "   " * i.abs, "*", "   " * j, (j > 0 ? "*\n" : "\n")
	i -= 1
	i >=0 ? j += 2 : j -= 2
end

 

分享到:
评论

相关推荐

    ruby-botnet:用于对自己的网站进行负载测试的工具……或更邪恶的目的

    用法要在您的计算机上本地运行僵尸网络,请使用以下命令: 服务器: ruby start_server.rb --host localhost --port 4567 --threads 10 --percentage 0.9 --routine ./routines/target_app/sample_routine.txt 客户...

    Ruby Programming Language 2008 pdf

    This book begins with a quick-start tutorial to the language, and then explains the language in detail from the bottom up: from lexical and syntactic structure to datatypes to expressions and ...

    oGood start for ruby

    NULL 博文链接:https://caerun.iteye.com/blog/2322971

    google-store-reports:从Google Play下载CSV报告(使用gsutil),并创建一个SQL脚本以将数据插入数据库中

    要从特定日期获取数据并将其导入数据库,请运行: ID=12345678901234567890 YEAR=2015 MONTH=7 ruby start.rb 您可以通过以下方式加载数据库,以获取Google提供的所有数据,而不用选择日期: ID=...

    apple-store-reports:从Apple Play下载报告并创建SQL脚本以将数据插入数据库中

    要从特定日期获取数据并将其导入数据库,请运行: VENDOR=12345678 YEAR=2015 MONTH=7 DAY=3 ruby start.rb 您可以运行以下命令,而不用选择日期,而是使用Apple提供的所有数据加载数据库: VENDOR=12345678 FROM=...

    异步事件驱动的RubyWeb应用框架Cramp.zip

    它建立在Ruby的EventMachine库之上,主要用于处理一些大量的开放连接 (如Comet系统或streaming APIs),整个过程都使用event-driven I/O。 Cramp使用Rails 3.0的ActiveSupport 和 ActiveModel库, 它会显示两层用于...

    Ruby的GUI构建工具ShenmeGUI.zip

    系统需求Ruby版本大于等于2.0.0。因为前后端通讯使用了websocket,所以需要使用支持websocket的浏览器。目前打开文件对话框只实现了windows版本,在Linux等使用会出错,以后会尝试在其他系统实现,除此之外对系统...

    机器人Ruby开发工具Artoo.zip

    Artoo 是一个小型的 Celluloid 机器人开发框架,提供简单强大... drone.start  drone.take_off  after(25.seconds) { drone.hover.land }  after(30.seconds) { drone.stop } end 标签:Artoo

    Ruby Cookbook, 2nd Edition

    If you come to this book wanting to gener‐ ate algorithmic music with Ruby then, yes, Recipe 13.14 will save you time over start‐ ing from scratch. It’s more likely that you’d never considered ...

    ruby-rails-sample

    foreman start 您的应用程序现在应该在上运行。 部署到 Heroku heroku create git push heroku master heroku run rake db:migrate heroku open 文档 有关在 Heroku 上使用 Ruby 的更多信息,请参阅这些开发中心...

    pwntools-ruby:Ruby上的pwntools!

    这是对start的利用,这对是一个挑战。 # encoding: ASCII-8BIT # The encoding line is important most time, or you'll get "\u0000" when using "\x00" in code, # which is NOT what we want when doing pwn... ...

    vim-ruby-heredoc-syntax:vim插件,用于在ruby here文档中高亮显示代码

    vim-ruby-heredoc语法这样可以在Ruby此处的文档代码块中...截屏选项 " Add syntax rulelet g: ruby_heredoc_syntax_filetypes = { \ " xml " : { \ " start " : " XML " , \} , \}" 'start' is heredoc start literal.

    Ruby的高性能HTTP服务器-Ruby开发

    : Server.init(6464,'root')类MyHandler def call(req)[200,{},[“ hello world”]]结束handler = MyHandler.new Agoo :: Server.handle(:GET,“ / hello”,handler)Agoo :: Server.start()#要运行此...

    Rails for .NET Developers (Facets of Ruby)

    We start with a gentle introduction to the object-oriented Ruby language with examples and direct comparisons to C#, so you'll quickly feel at home writing Ruby code for the first time. We then get ...

    polling:ruby 投票库

    轮询ruby 投票库安装将此行添加到应用程序的 Gemfile 中: gem 'polling'或者自己安装: $ gem install polling用法新界面 require 'polling'Polling.start 10 do puts "test" sleep 2end结果 #[debug]=&gt; start: ...

Global site tag (gtag.js) - Google Analytics