📄 program_4_8.cpp
字号:
// Program 4.8: Computes number of words and articles
#include <iostream>
#include <string>
using namespace std;
int main() {
// initialize counters ofr test analysis
int NumberOfWords = 0;
int NumberOfArticles = 0;
// begin string processing
string s;
cout << "Enter text for analysis" << endl << endl;
while (cin >> s) {
// found another word
++NumberOfWords;
// test if the word an article
if ((s == "the") || (s == "The") || (s == "an")
|| (s == "An") || (s == "a") || (s == "A")) {
// the word an article
++NumberOfArticles;
}
}
// display test statistics
cout << endl;
cout << "Text contains " << NumberOfWords
<< " Words of which " << NumberOfArticles
<< " are articles" << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -