Re: [問題] c++讀檔 不知道怎麼判斷文章已結束

看板C_and_CPP (C/C++)作者 (CA)時間16年前 (2009/03/24 23:21), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《kuro44776》之銘言: : http://rafb.net/p/jG7ks624.html : 以下是文章的一小段 : I have known Mary Lin for five years. : She is my best friend. Our relation is not like the friend. : We will make a fun and still share together a little more happy and unhappy things. : 題目要求要讀出單字數目 字元數目 還要在最後記算每個字母的出現次數 class Counter { public: /// 計算單字 void addWord( const string & ); /// 單字數目 int getWordCount() const; /// 字元數目 int getCharCount() const; /// 字母次數 vector<int> getABCount() const; }; string word; Counter counter; while( cin >> word ) { counter.addWord( word ); } cout << counter.getWordCount() << endl; cout << counter.getCharCount() << endl; cout << counter.getABCount() << endl; ---- 有電鋸為什麼要用手鋸?XD -- 自High筆記(半荒廢) http://legnaleurc.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.146.203.213

03/25 01:00, , 1F
題目要求你用手鋸 此題以解決
03/25 01:00, 1F

03/25 01:01, , 2F
我把str.length()當成while的判斷條件就行了...
03/25 01:01, 2F
文章代碼(AID): #19oFg1tF (C_and_CPP)
文章代碼(AID): #19oFg1tF (C_and_CPP)