本代码实现了一个统计文本文件中单词数量的功能。程序名为统计单词数(1400).cpp,适用于需要快速获取文档词汇量的场景。
```cpp
#include
#include
using namespace std;
int main() {
string word, sentence;
int ans = 0, d, i, j, len1, len2;
getline(cin, word);
getline(cin, sentence);
len1 = word.size();
len2 = sentence.size();
for (i = 0; i < len2; ++i) {
for (j = 0; j < len1; ++j) {
if(toupper(sentence[i + j]) != toupper(word[j]))
break;
if(i > 0 && sentence[i - 1] != )
break;
}
if(j == len1 && (sentence[i + j] == || i + j == len2)) {
ans++;
if(ans == 1)
d = i;
}
}
if(ans)
cout << ans << << d << endl;
else
cout << -1 << endl;
return 0;
}
```