作者legnaleurc (CA)
看板C_and_CPP
标题Re: [问题] c++读档 不知道怎麽判断文章已结束
时间Tue Mar 24 23:21:34 2009
※ 引述《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
1F:推 kuro44776:题目要求你用手锯 此题以解决 03/25 01:00
2F:→ kuro44776:我把str.length()当成while的判断条件就行了... 03/25 01:01