请大家帮我测试一下下面的代码。BCB5下,不能终止输入,怎么回事?

ntxs 2004-09-05 06:47:10
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
using namespace std;

int main(int argc, char* argv[])
{
istream_iterator<string> in(cin), eos;
vector<string> text;
copy(in, eos, inserter(text, text.begin()));
sort(text.begin(), text.end());
vector<string>::iterator it;
it = unique(text.begin(), text.end());
text.erase(it, text.end());
int line_cnt = 1;
for (vector<string>::iterator iter = text.begin();
iter != text.end(); iter++, line_cnt++)
{
cout<<*iter<<(line_cnt % 9 ? " " : "\n");
}
cout<<endl;
return 0;
}
...全文
84 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
falcon1210 2004-09-06
  • 打赏
  • 举报
回复
mark
  • 打赏
  • 举报
回复
我就是用这个方法结束输入的。
ntxs 2004-09-05
  • 打赏
  • 举报
回复
xteaj() 不能用这个方法 没用

fei180(飞180) 哪里有错误? 我这里编译通过一点问题没有
fei180 2004-09-05
  • 打赏
  • 举报
回复

我调试了下
错误蛮多
  • 打赏
  • 举报
回复
在最后增加一个^Z(Ctrl + Z),这是输入结束标志。
否则,程序认为输入没有结束。
renheihei 2004-09-05
  • 打赏
  • 举报
回复
mark

64,685

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧