Programming 板


LINE

※ 引述《raymondlea (看屁阿!!!)》之銘言: : Q1.Use the following sample data to trace your program step-by-step. : 13,20,5,8,97,16,80,27,32,45 不懂 : Q2.Write a Quick sort program to process a given setof data with N elements 歡迎愛用 Ruby, ptt 有看板 def qsort a case p = a[0] when nil then [] else qsort(a.select{|i|i<p}) + a.select{|i|i==p} + qsort(a.select{|i|i>p}) end end : Q3.Write down a computer program, in any programming language , which can : (a)Read in data file of 1000 items from a secondary storage. 第二個儲存裝置是指什麼? : (b)Have these items be sorted in descreasing order. a = read_from_secondary_storage.sort{|l,r|r<=>l} : (c)Store the sorted data into the secondary storage. save_to_secondary_storage a : (d)Describe and analyze your approach. 就把順序反過來就好 : Q4.Write a computer program , in any programming language , that can : (a)Read a set of data from a data file named "test.dat". : (b)Count the number of each digit in the set of extraced data. 歡迎愛用 Ruby, ptt 有看板 h = Hash.new 0 File.open('test.dat'){|f| f.each_byte{|b|h[b-48]+=1} } : Give brief comments about your method. 不懂 test.dat 內資料是什麼,假設是一串數字 : Q5.Write a program, in any programming language or pseudo codes , that can : read in an English text file "text950312.dat"from data of this drive A. : (a)Number of characters in this file. : (b)Number of words in this file. : (c)Number of lines in this file. 歡迎愛用 Ruby, ptt 有看板 c, w, l = Array.new(3, 0) File.open('text950312.dat'){|f| f.each_line{|ll| c += ll.size w += ll.scan(/\w+/).size l += 1 # L 和 1 長得好像 } } : write down proper comments in your program. 字元數:算長度 字 數:regex \w+ 行 數:算斷行 : 其實我不太清楚難易度是怎樣,因為研究所考計概時常會出這一類的題型,而我又沒程式 : 基礎,只是因為考的科系多考一科計概,只好硬著頭皮上去考囉 XD : 希望能有程式強者解救我一下,不管會哪一題都可以,我只想先把答案硬記下來, : 有時間在自己摸索看看,在此先謝謝囉!!! : 我也可以獻出所有的P幣來當作一點點的獎賞(雖然真的很少..就當是一點心意囉) 程式碼要背應該不太容易,還是歡迎來 ptt Ruby 板 XD -- #!/usr/bin/ruby [露比] /Programming (Kn|N)ight/ 看板《Ruby》 # if a dog nailed extra legs that http://webptt.com/m.aspx?n=bbs/Ruby/index.html # walks like an octopus, and Welcome ~Ruby@ptt~ # talks like an octopus, then ◢█◣ http://www.ruby-lang.org/ # we are happy to treat it as http://www.ruby-doc.org/ # if it were an octopus. http://www.rubyforge.org/ --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.58.12
1F:推 UNARYvvv:second storage 應該也是隨意吧,如硬碟220.132.114.113 03/14 17:44
2F:→ UNARYvvv:那邊看起來應該是要讓人練習讀檔而已~220.132.114.113 03/14 17:45
3F:→ UNARYvvv:打錯,應該是 secondary220.132.114.113 03/14 17:46
4F:推 leicheong:另外總覺得Q2和Q1倒置了... rO_O 58.152.219.79 03/14 20:25
5F:推 godfat:有道理 O_o 220.134.30.220 03/15 18:00







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BuyTogether站內搜尋

TOP