Ruby
skyboyish
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Ruby学习之路——编程实践【1】 打印1到n的所有质数
做测试的,想好好学习Ruby,在这里记下用Ruby写的一些小程序,以备日后查用。编程实现【1】 2012-06-04 打印1到n的所有质数 class Sushu @@flag = false def printSushu(n) for i in (2..n) if i == 2 then @@flag = true els原创 2012-06-04 18:02:47 · 645 阅读 · 0 评论 -
Ruby学习之路——编程实践【2】 打印出1到n的所有对称数
编程实现【2】 2012-06-04打印出1到n的所有对称数class FindOddNumber def getNumberCount(n) count = 1 while n/10>=1 n = n/10 count += 1 end return count end def getTheOne(nu原创 2012-06-04 18:12:00 · 713 阅读 · 0 评论 -
Ruby学习之路——编程实践【4】 杨辉三角
编程实践【4】 2012-06-05杨辉三角(无格式输出)class Yanghui def initialize(row) @row = row @intArr = Array.new 1.upto(@row) do |i| intArrIn = Array.new 1.upto(i) do |j| in原创 2012-06-05 10:26:02 · 474 阅读 · 0 评论 -
Ruby学习之路——编程实践【4】(续) 杨辉三角,带格式输出
编程实践【4】(续) 2012-06-05杨辉三角(带格式输出),比之前的增加一个方法和一行语句class Yanghui def initialize(row) @row = row @intArr = Array.new 1.upto(@row) do |i| intArrIn = Array.new 1.upto(i原创 2012-06-05 11:30:20 · 760 阅读 · 0 评论 -
Ruby学习之路——编程实践【3】 排序——快速排序
编程实现【3】 2012-06-04 实现快速排序arrInt = [23, 2, 56, 89, 12, 45]def swap(arrInt, m, n) temp = arrInt[m] arrInt[m] = arrInt[n] arrInt[n] = tempenddef quickSort(arrInt, low, high) mi原创 2012-06-04 18:13:21 · 527 阅读 · 0 评论 -
Ruby学习之路——编程实践【5】 选择排序
Ruby学习之路——编程实践【5】 2012-06-08选择排序def selectSort(arrInt, low = 0, high = arrInt.length - 1) 0.upto(high - 1) do |i| small = i i.upto(high) do |j| if arrInt[j] < arrInt[small] th原创 2012-06-08 11:25:18 · 494 阅读 · 0 评论
分享