是學校的課程作業
要求掌握ruby的簡單使用
所以**沒有實際意義
只是拿來熟悉ruby**的語法和結構等
**是在vs code裡面編寫和執行的module output
def print_hush(a)
a.each do | item, price |
puts "# => #"
endend
def print_array(b)
length = b.length
length.times do |t|
print "# "
end
puts "\n"
enddef print_string(c)
puts c
endendclass sort
include output
def array_sort(a)
return a.sort
end
def hush_sort(x)
return x.sort
enddef string_sort(x)
y = x.split("*")
return y.sort
endendend
puts "\nbefore sort(hush):"
b2 =
puts b2
s2 = sort.new
puts "sorted:"
s2.print_hush(s2.hush_sort(b2))
puts "\nbefore sort(string):"
def gen_rand_str(len)
rand_indexes = (0...len).collect
[*('a'..'z'),*('a'..'z')].values_at(*rand_indexes).join
enda15=gen_rand_str(15)
a8=gen_rand_str(8)
a12=gen_rand_str(12)
b3 = a15 +'*'+ a8 +'*' + a12
puts a15 +"\n"+ a8 + "\n" + a12
s3 = sort.new
puts "sorted:"
s3.print_string(s3.string_sort(b3))
環境配置很簡單
有興趣的也可以自己嘗試一下
第乙個小程式
2.建立pages目錄檔案 作用是放各個頁面的 3.建立頁面 給頁面起名字,並建立四個檔案 1 js 邏輯的實現 2 json 負責標題欄和一些狀態列 3 wxml 頁面文字 4 wxss 頁面樣式 4.把內容元素封裝在view內部,寫法 內容 5.這節課需要用到三個元件 文字 按鈕 1 2 文字 ...
用Ruby寫第乙個程式
安裝了個ruby193,寫了第乙個ruby程式,來記錄下自己學習點滴。首先在ruby的新建個資料夾sample,再新新增個檔案,名字helloworld.rb 內容就是 puts hello,world 當然也可以先宣告變數,如後再用puts語句 a hello,world puts a當然也可以先...
c 第乙個小程式
include using namespace std int main const int size 50 定義大小。char name size cout please input you name n 提示 cin name 輸入 cout hello world int main char ...