我可以用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'的大量用法。 –