加载中...

习题 9: 印出,印出,印出


  1. # Here's some new strange stuff, remember type it exactly.
  2. days = "Mon Tue Wed Thu Fri Sat Sun"
  3. months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
  4. puts "Here are the days: ", days
  5. puts "Here are the months: ", months
  6. puts <<PARAGRAPH
  7. There's something going on here.
  8. With the three double-quotes.
  9. We'll be able to type as much as we like.
  10. Even 4 lines if we want, or 5, or 6.
  11. PARAGRAPH

你应该看到的结果

  1. $ ruby ex9.rb
  2. Here are the days:
  3. Mon Tue Wed Thu Fri Sat Sun
  4. Here are the months:
  5. Jan
  6. Feb
  7. Mar
  8. Apr
  9. May
  10. Jun
  11. Jul
  12. Aug
  13. There's something going on here.
  14. With the three double-quotes.
  15. We'll be able to type as much as we like.
  16. Even 4 lines if we want, or 5, or 6.

加分习题

  1. 自己检查结果,记录你犯过的错误,并且在下个练习中尽量不犯相同的错误。

还没有评论.