close
標題:

如何用C programming 來寫一個程式去計算一句句子or a phrase在一篇文章內出現的次數

發問:

如何用C programming 來寫一個程式去計算一句句子or a phrase在一篇文章內出現的次數Pls show the steps in detail. 10 points will be awarded to the best answerer.

最佳解答:

免費註冊體驗

 

此文章來自奇摩知識+如有不便請留言告知

因為文字檔案的容量很難預計,建議用「即時傳譯」的方式,就是讀一段、處理一段。 演算法 Algorithm 把計數器歸零 用fgets()從文字檔讀一段以'\n'為分界的文字 用strstr()來搜尋目標字串 找到就把計數器加一 重複3及4直至全段字串已掃瞄完畢 重複2至5直至全個檔案已掃瞄完畢 程式原碼 Program Source Code 圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/phrscntr01.gif 圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/phrscntr02.gif 圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/phrscntr03.gif 圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/phrscntr04.gif 原碼下載 Download 圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/rightarrow.gif phrscntr.c 編譯 Compilation Microsoft Visual C++ 或 任何相容之編譯器 執行 Execution phrscntr 顯示「線上協助」(on-line help) phrscntr myfile.txt -s " is a " 以「大小寫不同」(case-sensitive)方式,數“myfile.txt”檔內的“ is a ”字串出現的次數 phrscntr "c:\My Documents\yourfile.txt" -i the 以「大小寫相同」(case-insensitive)方式,數“c:\My Documents\yourfile.txt”檔內“the”字串出的現次數

其他解答:
arrow
arrow

    ddhdxb5 發表在 痞客邦 留言(0) 人氣()