如何解决为什么我的 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 举报,一经查实,本站将立刻删除。