为什么我的 CodeBlocks 输出控制台不响应向量?

问题描述

我正在尝试复制 Bjarne Stroustrup 的“编程:使用 C++ 的原则和实践”(2016 版)中的字典示例

示例的目标是,输入一些单词,将它们按顺序写出,没有任何重复。

我使用的是 CodeBlocks 20.03,当我尝试运行该示例时,终端上没有显示任何内容。当我输入一些输入时,它没有出现任何错误消息,但没有响应。

这是代码

//simple dictionary: list of sorted words
#include "std_lib_facilities.h"; 
int main()
{
    vector<string> words;
    for(string temp; cin>>temp; )        //read whitespace-separated words
        words.push_back(temp);     //put into vector
    cout << "Number of words: " << words.size() << '\n';
    sort(words);                                     //sort the words
    for (int i = 0; i<words.size(); ++i)
        if (i==0 || words[i-1]!=words[i])//is this a new word?
        cout << words[i] << "\n";
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)