我可以用g ++编译代码,以及cin也不错。但是,在按输入后我没有输出,我可以继续输入单词。有什么问题?为什么代码没有cout?
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
map<string, size_t> word_count;
string word;
while (cin>>word) {
++word_count[word];
}
for (auto &w : word_count) {
cout<<w.first<<" occurs "<<w.second<<" times"<<endl;
}
return 0;
}
你是什么意思 “的代码有没有COUT” 和 “我没有得到任何COUT”?我在这段代码中看到了'cout'的大量用法。 –